Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(33)

Side by Side Diff: gears/database2/connection.h

Issue 717: Database2Values, argument conversion implemented (Closed) SVN Base: http://google-gears.googlecode.com/svn/contrib/dimitri.glazkov/database2/
Patch Set: Created 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2008, Google Inc. 1 // Copyright 2008, Google Inc.
2 // 2 //
3 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are met: 4 // modification, are permitted provided that the following conditions are met:
5 // 5 //
6 // 1. Redistributions of source code must retain the above copyright notice, 6 // 1. Redistributions of source code must retain the above copyright notice,
7 // this list of conditions and the following disclaimer. 7 // this list of conditions and the following disclaimer.
8 // 2. Redistributions in binary form must reproduce the above copyright notice, 8 // 2. Redistributions in binary form must reproduce the above copyright notice,
9 // this list of conditions and the following disclaimer in the documentation 9 // this list of conditions and the following disclaimer in the documentation
10 // and/or other materials provided with the distribution. 10 // and/or other materials provided with the distribution.
(...skipping 14 matching lines...) Show 10 above Show 10 below
25 25
26 #ifndef GEARS_DATABASE2_CONNECTION_H__ 26 #ifndef GEARS_DATABASE2_CONNECTION_H__
27 #define GEARS_DATABASE2_CONNECTION_H__ 27 #define GEARS_DATABASE2_CONNECTION_H__
28 28
29 #include "gears/base/common/common.h" 29 #include "gears/base/common/common.h"
30 #include "gears/base/common/js_types.h" 30 #include "gears/base/common/js_types.h"
31 #include "gears/base/common/scoped_refptr.h" 31 #include "gears/base/common/scoped_refptr.h"
32 #include "gears/base/common/security_model.h" 32 #include "gears/base/common/security_model.h"
33 #include "gears/base/common/string16.h" 33 #include "gears/base/common/string16.h"
34 #include "gears/third_party/sqlite_google/preprocessed/sqlite3.h" 34 #include "gears/third_party/sqlite_google/preprocessed/sqlite3.h"
35
36 class Database2Values;
35 37
36 class Database2RowHandlerInterface { 38 class Database2RowHandlerInterface {
37 public: 39 public:
38 Database2RowHandlerInterface() {}; 40 Database2RowHandlerInterface() {};
39 ~Database2RowHandlerInterface() {}; 41 ~Database2RowHandlerInterface() {};
40 42
41 virtual void Begin() = 0; 43 virtual void Begin() = 0;
42 // TODO(dimitri.glazkov): Add row data parameter(s) 44 // TODO(dimitri.glazkov): Add row data parameter(s)
43 virtual void HandleRow() = 0; 45 virtual void HandleRow() = 0;
44 virtual void End() = 0; 46 virtual void End() = 0;
45 47
46 DISALLOW_EVIL_CONSTRUCTORS(Database2RowHandlerInterface); 48 DISALLOW_EVIL_CONSTRUCTORS(Database2RowHandlerInterface);
47 }; 49 };
48 50
49 // Encapsulates database operations, opens and closes database connection 51 // Encapsulates database operations, opens and closes database connection
50 class Database2Connection : public RefCounted { 52 class Database2Connection : public RefCounted {
51 public: 53 public:
52 // lazily initialized 54 // lazily initialized
53 Database2Connection(const std::string16 &name, 55 Database2Connection(const std::string16 &name,
54 const SecurityOrigin &origin) : 56 const SecurityOrigin &origin) :
55 name_(name), origin_(origin) {} 57 name_(name), origin_(origin) {}
56 ~Database2Connection() { 58 ~Database2Connection() {
57 // close connection 59 // close connection
58 } 60 }
59 61
60 bool OpenAndVerifyVersion(const std::string16 &database_version); 62 bool OpenAndVerifyVersion(const std::string16 &database_version);
61 bool Execute(const std::string16 &statement, 63 bool Execute(const std::string16 &statement,
62 const int num_arguments, 64 Database2Values *arguments,
63 const JsParamToSend *arguments,
64 Database2RowHandlerInterface *row_handler); 65 Database2RowHandlerInterface *row_handler);
65 bool Begin(); 66 bool Begin();
66 void Rollback(); 67 void Rollback();
67 bool Commit(); 68 bool Commit();
68 69
69 int error_code() const { return error_code_; } 70 int error_code() const { return error_code_; }
70 std::string16 error_message() const { return error_message_; } 71 std::string16 error_message() const { return error_message_; }
71 72
72 private: 73 private:
73 bool bogus_version_; 74 bool bogus_version_;
74 int expected_version_; 75 int expected_version_;
75 76
76 std::string16 error_message_; 77 std::string16 error_message_;
77 int error_code_; 78 int error_code_;
78 79
79 sqlite3 *handle_; 80 sqlite3 *handle_;
80 std::string16 name_; 81 std::string16 name_;
81 SecurityOrigin origin_; 82 SecurityOrigin origin_;
82 83
83 DISALLOW_EVIL_CONSTRUCTORS(Database2Connection); 84 DISALLOW_EVIL_CONSTRUCTORS(Database2Connection);
84 }; 85 };
85 86
86 #endif // GEARS_DATABASE2_CONNECTION_H__ 87 #endif // GEARS_DATABASE2_CONNECTION_H__
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r338