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

Delta Between Two Patch Sets: gears/database2/connection.h

Issue 717: Database2Values, argument conversion implemented (Closed) SVN Base: http://google-gears.googlecode.com/svn/contrib/dimitri.glazkov/database2/
Left Patch Set: Created 3 months, 2 weeks ago
Right Patch Set: ready for another look. Created 3 months, 2 weeks 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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.
11 // 3. Neither the name of Google Inc. nor the names of its contributors may be 11 // 3. Neither the name of Google Inc. nor the names of its contributors may be
12 // used to endorse or promote products derived from this software without 12 // used to endorse or promote products derived from this software without
13 // specific prior written permission. 13 // specific prior written permission.
14 // 14 //
15 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 15 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 17 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
18 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 18 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 21 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 22 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 23 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 35
36 class Database2Values; 36 class Database2Values;
37 37
38 class Database2RowHandlerInterface { 38 class Database2RowHandlerInterface {
39 public: 39 public:
40 Database2RowHandlerInterface() {}; 40 Database2RowHandlerInterface() {};
41 ~Database2RowHandlerInterface() {}; 41 ~Database2RowHandlerInterface() {};
42 42
43 virtual void Begin() = 0; 43 virtual void Begin() = 0;
44 // TODO(dimitri.glazkov): Add row data parameter(s) 44 // TODO(dimitri.glazkov): Add row data parameter(s)
45 virtual void HandleRow() = 0; 45 virtual void HandleRow() = 0;
46 virtual void End() = 0; 46 virtual void End() = 0;
47 47
48 DISALLOW_EVIL_CONSTRUCTORS(Database2RowHandlerInterface); 48 DISALLOW_EVIL_CONSTRUCTORS(Database2RowHandlerInterface);
49 }; 49 };
50 50
51 // Encapsulates database operations, opens and closes database connection 51 // Encapsulates database operations, opens and closes database connection
52 class Database2Connection : public RefCounted { 52 class Database2Connection : public RefCounted {
53 public: 53 public:
54 // lazily initialized 54 // lazily initialized
55 Database2Connection(const std::string16 &name, 55 Database2Connection(const std::string16 &name,
56 const SecurityOrigin &origin) : 56 const SecurityOrigin &origin) :
57 name_(name), origin_(origin) {} 57 name_(name), origin_(origin) {}
58 ~Database2Connection() { 58 ~Database2Connection() {
59 // close connection 59 // close connection
60 } 60 }
61 61
62 bool OpenAndVerifyVersion(const std::string16 &database_version); 62 bool OpenAndVerifyVersion(const std::string16 &database_version);
63 bool Execute(const std::string16 &statement, 63 bool Execute(const std::string16 &statement,
64 Database2Values *arguments, 64 Database2Values *arguments,
65 Database2RowHandlerInterface *row_handler); 65 Database2RowHandlerInterface *row_handler);
66 bool Begin(); 66 bool Begin();
67 void Rollback(); 67 void Rollback();
68 bool Commit(); 68 bool Commit();
69 69
70 int error_code() const { return error_code_; } 70 int error_code() const { return error_code_; }
71 std::string16 error_message() const { return error_message_; } 71 std::string16 error_message() const { return error_message_; }
72 72
73 private: 73 private:
74 bool bogus_version_; 74 bool bogus_version_;
75 int expected_version_; 75 int expected_version_;
76 76
77 std::string16 error_message_; 77 std::string16 error_message_;
78 int error_code_; 78 int error_code_;
79 79
80 sqlite3 *handle_; 80 sqlite3 *handle_;
81 std::string16 name_; 81 std::string16 name_;
82 SecurityOrigin origin_; 82 SecurityOrigin origin_;
83 83
84 DISALLOW_EVIL_CONSTRUCTORS(Database2Connection); 84 DISALLOW_EVIL_CONSTRUCTORS(Database2Connection);
85 }; 85 };
86 86
87 #endif // GEARS_DATABASE2_CONNECTION_H__ 87 #endif // GEARS_DATABASE2_CONNECTION_H__
LEFTRIGHT

Powered by Google App Engine
This is Rietveld r292