Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: sql/connection.h

Issue 11141012: Move ErrorDelegate to its own file and add static utility functions to ErrorDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win build Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/net/sqlite_persistent_cookie_store.cc ('k') | sql/diagnostic_error_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SQL_CONNECTION_H_ 5 #ifndef SQL_CONNECTION_H_
6 #define SQL_CONNECTION_H_ 6 #define SQL_CONNECTION_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // ErrorDelegate defines the interface to implement error handling and recovery 76 // ErrorDelegate defines the interface to implement error handling and recovery
77 // for sqlite operations. This allows the rest of the classes to return true or 77 // for sqlite operations. This allows the rest of the classes to return true or
78 // false while the actual error code and causing statement are delivered using 78 // false while the actual error code and causing statement are delivered using
79 // the OnError() callback. 79 // the OnError() callback.
80 // The tipical usage is to centralize the code designed to handle database 80 // The tipical usage is to centralize the code designed to handle database
81 // corruption, low-level IO errors or locking violations. 81 // corruption, low-level IO errors or locking violations.
82 class SQL_EXPORT ErrorDelegate { 82 class SQL_EXPORT ErrorDelegate {
83 public: 83 public:
84 virtual ~ErrorDelegate(); 84 virtual ~ErrorDelegate();
85 85
86 // |error| is an sqlite result code as seen in sqlite\preprocessed\sqlite3.h 86 // |error| is an sqlite result code as seen in sqlite3.h. |connection| is the
87 // |connection| is db connection where the error happened and |stmt| is 87 // db connection where the error happened and |stmt| is our best guess at the
88 // our best guess at the statement that triggered the error. Do not store 88 // statement that triggered the error. Do not store these pointers.
89 // these pointers.
90 // 89 //
91 // |stmt| MAY BE NULL if there is no statement causing the problem (i.e. on 90 // |stmt| MAY BE NULL if there is no statement causing the problem (i.e. on
92 // initialization). 91 // initialization).
93 // 92 //
94 // If the error condition has been fixed an the original statement succesfuly 93 // If the error condition has been fixed and the original statement succesfuly
95 // re-tried then returning SQLITE_OK is appropiate; otherwise is recomended 94 // re-tried then returning SQLITE_OK is appropriate; otherwise it is
96 // that you return the original |error| or the appropiae error code. 95 // recommended that you return the original |error| or the appropriate error
96 // code.
97 virtual int OnError(int error, Connection* connection, Statement* stmt) = 0; 97 virtual int OnError(int error, Connection* connection, Statement* stmt) = 0;
98 }; 98 };
99 99
100 class SQL_EXPORT Connection { 100 class SQL_EXPORT Connection {
101 private: 101 private:
102 class StatementRef; // Forward declaration, see real one below. 102 class StatementRef; // Forward declaration, see real one below.
103 103
104 public: 104 public:
105 // The database is opened by calling Open[InMemory](). Any uncommitted 105 // The database is opened by calling Open[InMemory](). Any uncommitted
106 // transactions will be rolled back when this object is deleted. 106 // transactions will be rolled back when this object is deleted.
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 // This object handles errors resulting from all forms of executing sqlite 443 // This object handles errors resulting from all forms of executing sqlite
444 // commands or statements. It can be null which means default handling. 444 // commands or statements. It can be null which means default handling.
445 scoped_ptr<ErrorDelegate> error_delegate_; 445 scoped_ptr<ErrorDelegate> error_delegate_;
446 446
447 DISALLOW_COPY_AND_ASSIGN(Connection); 447 DISALLOW_COPY_AND_ASSIGN(Connection);
448 }; 448 };
449 449
450 } // namespace sql 450 } // namespace sql
451 451
452 #endif // SQL_CONNECTION_H_ 452 #endif // SQL_CONNECTION_H_
OLDNEW
« no previous file with comments | « chrome/browser/net/sqlite_persistent_cookie_store.cc ('k') | sql/diagnostic_error_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698