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

Side by Side Diff: app/sql/connection.h

Issue 3452030: FBTF: Moves code to the headers. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 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
« no previous file with comments | « app/resource_bundle.cc ('k') | app/sql/connection.cc » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 APP_SQL_CONNECTION_H_ 5 #ifndef APP_SQL_CONNECTION_H_
6 #define APP_SQL_CONNECTION_H_ 6 #define APP_SQL_CONNECTION_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 class Connection; 70 class Connection;
71 71
72 // ErrorDelegate defines the interface to implement error handling and recovery 72 // ErrorDelegate defines the interface to implement error handling and recovery
73 // for sqlite operations. This allows the rest of the classes to return true or 73 // for sqlite operations. This allows the rest of the classes to return true or
74 // false while the actual error code and causing statement are delivered using 74 // false while the actual error code and causing statement are delivered using
75 // the OnError() callback. 75 // the OnError() callback.
76 // The tipical usage is to centralize the code designed to handle database 76 // The tipical usage is to centralize the code designed to handle database
77 // corruption, low-level IO errors or locking violations. 77 // corruption, low-level IO errors or locking violations.
78 class ErrorDelegate : public base::RefCounted<ErrorDelegate> { 78 class ErrorDelegate : public base::RefCounted<ErrorDelegate> {
79 public: 79 public:
80 ErrorDelegate();
81
80 // |error| is an sqlite result code as seen in sqlite\preprocessed\sqlite3.h 82 // |error| is an sqlite result code as seen in sqlite\preprocessed\sqlite3.h
81 // |connection| is db connection where the error happened and |stmt| is 83 // |connection| is db connection where the error happened and |stmt| is
82 // our best guess at the statement that triggered the error. Do not store 84 // our best guess at the statement that triggered the error. Do not store
83 // these pointers. 85 // these pointers.
84 // 86 //
85 // |stmt| MAY BE NULL if there is no statement causing the problem (i.e. on 87 // |stmt| MAY BE NULL if there is no statement causing the problem (i.e. on
86 // initialization). 88 // initialization).
87 // 89 //
88 // If the error condition has been fixed an the original statement succesfuly 90 // If the error condition has been fixed an the original statement succesfuly
89 // re-tried then returning SQLITE_OK is appropiate; otherwise is recomended 91 // re-tried then returning SQLITE_OK is appropiate; otherwise is recomended
90 // that you return the original |error| or the appropiae error code. 92 // that you return the original |error| or the appropiae error code.
91 virtual int OnError(int error, Connection* connection, Statement* stmt) = 0; 93 virtual int OnError(int error, Connection* connection, Statement* stmt) = 0;
92 94
93 protected: 95 protected:
94 friend class base::RefCounted<ErrorDelegate>; 96 friend class base::RefCounted<ErrorDelegate>;
95 97
96 virtual ~ErrorDelegate() {} 98 virtual ~ErrorDelegate();
97 }; 99 };
98 100
99 class Connection { 101 class Connection {
100 private: 102 private:
101 class StatementRef; // Forward declaration, see real one below. 103 class StatementRef; // Forward declaration, see real one below.
102 104
103 public: 105 public:
104 // The database is opened by calling Open[InMemory](). Any uncommitted 106 // The database is opened by calling Open[InMemory](). Any uncommitted
105 // transactions will be rolled back when this object is deleted. 107 // transactions will be rolled back when this object is deleted.
106 Connection(); 108 Connection();
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 // This object handles errors resulting from all forms of executing sqlite 374 // This object handles errors resulting from all forms of executing sqlite
373 // commands or statements. It can be null which means default handling. 375 // commands or statements. It can be null which means default handling.
374 scoped_refptr<ErrorDelegate> error_delegate_; 376 scoped_refptr<ErrorDelegate> error_delegate_;
375 377
376 DISALLOW_COPY_AND_ASSIGN(Connection); 378 DISALLOW_COPY_AND_ASSIGN(Connection);
377 }; 379 };
378 380
379 } // namespace sql 381 } // namespace sql
380 382
381 #endif // APP_SQL_CONNECTION_H_ 383 #endif // APP_SQL_CONNECTION_H_
OLDNEW
« no previous file with comments | « app/resource_bundle.cc ('k') | app/sql/connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698