OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 // Refcounting allows us to give these statements out to sql::Statement | 287 // Refcounting allows us to give these statements out to sql::Statement |
288 // objects while also optionally maintaining a cache of compiled statements | 288 // objects while also optionally maintaining a cache of compiled statements |
289 // by just keeping a refptr to these objects. | 289 // by just keeping a refptr to these objects. |
290 // | 290 // |
291 // A statement ref can be valid, in which case it can be used, or invalid to | 291 // A statement ref can be valid, in which case it can be used, or invalid to |
292 // indicate that the statement hasn't been created yet, has an error, or has | 292 // indicate that the statement hasn't been created yet, has an error, or has |
293 // been destroyed. | 293 // been destroyed. |
294 // | 294 // |
295 // The Connection may revoke a StatementRef in some error cases, so callers | 295 // The Connection may revoke a StatementRef in some error cases, so callers |
296 // should always check validity before using. | 296 // should always check validity before using. |
297 class StatementRef : public base::RefCounted<StatementRef> { | 297 class SQL_EXPORT StatementRef : public base::RefCounted<StatementRef> { |
298 public: | 298 public: |
299 // Default constructor initializes to an invalid statement. | 299 // Default constructor initializes to an invalid statement. |
300 StatementRef(); | 300 StatementRef(); |
301 StatementRef(Connection* connection, sqlite3_stmt* stmt); | 301 StatementRef(Connection* connection, sqlite3_stmt* stmt); |
302 | 302 |
303 // When true, the statement can be used. | 303 // When true, the statement can be used. |
304 bool is_valid() const { return !!stmt_; } | 304 bool is_valid() const { return !!stmt_; } |
305 | 305 |
306 // If we've not been linked to a connection, this will be NULL. Guaranteed | 306 // If we've not been linked to a connection, this will be NULL. Guaranteed |
307 // non-NULL when is_valid(). | 307 // non-NULL when is_valid(). |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 // This object handles errors resulting from all forms of executing sqlite | 379 // This object handles errors resulting from all forms of executing sqlite |
380 // commands or statements. It can be null which means default handling. | 380 // commands or statements. It can be null which means default handling. |
381 scoped_refptr<ErrorDelegate> error_delegate_; | 381 scoped_refptr<ErrorDelegate> error_delegate_; |
382 | 382 |
383 DISALLOW_COPY_AND_ASSIGN(Connection); | 383 DISALLOW_COPY_AND_ASSIGN(Connection); |
384 }; | 384 }; |
385 | 385 |
386 } // namespace sql | 386 } // namespace sql |
387 | 387 |
388 #endif // SQL_CONNECTION_H_ | 388 #endif // SQL_CONNECTION_H_ |
OLD | NEW |