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

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

Issue 717: Database2Values, argument conversion implemented (Closed) SVN Base: http://google-gears.googlecode.com/svn/contrib/dimitri.glazkov/database2/
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:
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.
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 #include "gears/database2/connection.h" 26 #include "gears/database2/connection.h"
27 #include "gears/database2/statement.h"
27 28
28 // TODO(dimitri.glazkov): implement actual database operations. For now, all 29 // TODO(dimitri.glazkov): implement actual database operations. For now, all
29 // operations pretend to succeed to facilitate in-progress testing 30 // operations pretend to succeed to facilitate in-progress testing
30 31
31 bool Database2Connection::OpenAndVerifyVersion( 32 bool Database2Connection::OpenAndVerifyVersion(
32 const std::string16 &database_version) { 33 const std::string16 &database_version) {
33 // open database if not already open 34 // open database if not already open
34 // read expected_version (user_version value) 35 // read expected_version (user_version value)
35 // read version from Permissions.db 36 // read version from Permissions.db
36 // if database_version is not an empty value or null, 37 // if database_version is not an empty value or null,
37 if (!database_version.empty()) { 38 if (!database_version.empty()) {
38 // if database_version matches version 39 // if database_version matches version
39 // return true 40 // return true
40 // otherwise, 41 // otherwise,
41 return false; 42 return false;
42 // return true 43 // return true
43 } 44 }
44 return true; 45 return true;
45 } 46 }
46 47
47 bool Database2Connection::Execute(const std::string16 &statement, 48 bool Database2Connection::Execute(const std::string16 &statement,
48 const int num_arguments, 49 Database2Values *arguments,
49 const JsParamToSend *arguments,
50 Database2RowHandlerInterface *row_handler) { 50 Database2RowHandlerInterface *row_handler) {
51 // if (bogus_version_) { 51 // if (bogus_version_) {
52 // set error code to "version mismatch" (error code 2) 52 // set error code to "version mismatch" (error code 2)
53 // } 53 // }
54 // prepare 54 // prepare
55 // step, for each row, call row_handler->HandleRow(..); 55 // step, for each row, call row_handler->HandleRow(..);
56 // if error, set error code and message, return false; 56 // if error, set error code and message, return false;
57 // return true upon success 57 // return true upon success
58 return true; 58 return true;
59 } 59 }
60 60
61 bool Database2Connection::Begin() { 61 bool Database2Connection::Begin() {
62 // execute BEGIN 62 // execute BEGIN
63 // if error, set error code and message, return false 63 // if error, set error code and message, return false
64 // read actual_version, if doesn't match expected_version_, 64 // read actual_version, if doesn't match expected_version_,
65 // set bogus_version_ flag 65 // set bogus_version_ flag
66 // return true upon success 66 // return true upon success
67 return true; 67 return true;
68 } 68 }
69 69
70 void Database2Connection::Rollback() { 70 void Database2Connection::Rollback() {
71 // execute ROLLBACK 71 // execute ROLLBACK
72 // don't remember or handle errors 72 // don't remember or handle errors
73 } 73 }
74 74
75 bool Database2Connection::Commit() { 75 bool Database2Connection::Commit() {
76 // execute COMMIT 76 // execute COMMIT
77 // if error, set error code and message, return false 77 // if error, set error code and message, return false
78 // return true upon success 78 // return true upon success
79 return true; 79 return true;
80 } 80 }
OLDNEW

Powered by Google App Engine
This is Rietveld r292