Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/threading/thread_restrictions.h" | 19 #include "base/threading/thread_restrictions.h" |
| 20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "base/trace_event/memory_dump_provider.h" | |
| 21 #include "sql/sql_export.h" | 22 #include "sql/sql_export.h" |
| 22 | 23 |
| 23 struct sqlite3; | 24 struct sqlite3; |
| 24 struct sqlite3_stmt; | 25 struct sqlite3_stmt; |
| 25 | 26 |
| 26 namespace base { | 27 namespace base { |
| 27 class FilePath; | 28 class FilePath; |
| 28 class HistogramBase; | 29 class HistogramBase; |
| 29 } | 30 } |
| 30 | 31 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 TimeSource() {} | 96 TimeSource() {} |
| 96 virtual ~TimeSource() {} | 97 virtual ~TimeSource() {} |
| 97 | 98 |
| 98 // Return the current time (by default base::TimeTicks::Now()). | 99 // Return the current time (by default base::TimeTicks::Now()). |
| 99 virtual base::TimeTicks Now(); | 100 virtual base::TimeTicks Now(); |
| 100 | 101 |
| 101 private: | 102 private: |
| 102 DISALLOW_COPY_AND_ASSIGN(TimeSource); | 103 DISALLOW_COPY_AND_ASSIGN(TimeSource); |
| 103 }; | 104 }; |
| 104 | 105 |
| 105 class SQL_EXPORT Connection { | 106 class SQL_EXPORT Connection : public base::trace_event::MemoryDumpProvider { |
| 106 private: | 107 private: |
|
Primiano Tucci (use gerrit)
2015/09/30 10:26:56
Just to have a rough idea, how many connections ca
ssid
2015/10/02 17:06:10
It is usually less than 2 dozens.
| |
| 107 class StatementRef; // Forward declaration, see real one below. | 108 class StatementRef; // Forward declaration, see real one below. |
| 108 | 109 |
| 109 public: | 110 public: |
| 110 // The database is opened by calling Open[InMemory](). Any uncommitted | 111 // The database is opened by calling Open[InMemory](). Any uncommitted |
| 111 // transactions will be rolled back when this object is deleted. | 112 // transactions will be rolled back when this object is deleted. |
| 112 Connection(); | 113 Connection(); |
| 113 ~Connection(); | 114 ~Connection() override; |
| 114 | 115 |
| 115 // Pre-init configuration ---------------------------------------------------- | 116 // Pre-init configuration ---------------------------------------------------- |
| 116 | 117 |
| 117 // Sets the page size that will be used when creating a new database. This | 118 // Sets the page size that will be used when creating a new database. This |
| 118 // must be called before Init(), and will only have an effect on new | 119 // must be called before Init(), and will only have an effect on new |
| 119 // databases. | 120 // databases. |
| 120 // | 121 // |
| 121 // From sqlite.org: "The page size must be a power of two greater than or | 122 // From sqlite.org: "The page size must be a power of two greater than or |
| 122 // equal to 512 and less than or equal to SQLITE_MAX_PAGE_SIZE. The maximum | 123 // equal to 512 and less than or equal to SQLITE_MAX_PAGE_SIZE. The maximum |
| 123 // value for SQLITE_MAX_PAGE_SIZE is 32768." | 124 // value for SQLITE_MAX_PAGE_SIZE is 32768." |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 // running the following statement at a sqlite3 command-line: | 455 // running the following statement at a sqlite3 command-line: |
| 455 // SELECT type, name, tbl_name, sql FROM sqlite_master ORDER BY 1, 2, 3, 4; | 456 // SELECT type, name, tbl_name, sql FROM sqlite_master ORDER BY 1, 2, 3, 4; |
| 456 std::string GetSchema() const; | 457 std::string GetSchema() const; |
| 457 | 458 |
| 458 // Clients which provide an error_callback don't see the | 459 // Clients which provide an error_callback don't see the |
| 459 // error-handling at the end of OnSqliteError(). Expose to allow | 460 // error-handling at the end of OnSqliteError(). Expose to allow |
| 460 // those clients to work appropriately with ScopedErrorIgnorer in | 461 // those clients to work appropriately with ScopedErrorIgnorer in |
| 461 // tests. | 462 // tests. |
| 462 static bool ShouldIgnoreSqliteError(int error); | 463 static bool ShouldIgnoreSqliteError(int error); |
| 463 | 464 |
| 465 // base::trace_event::MemoryDumpProvider implementation. | |
| 466 bool OnMemoryDump( | |
| 467 const base::trace_event::MemoryDumpArgs& args, | |
| 468 base::trace_event::ProcessMemoryDump* process_memory_dump) override; | |
| 469 | |
| 464 private: | 470 private: |
| 465 // For recovery module. | 471 // For recovery module. |
| 466 friend class Recovery; | 472 friend class Recovery; |
| 467 | 473 |
| 468 // Allow test-support code to set/reset error ignorer. | 474 // Allow test-support code to set/reset error ignorer. |
| 469 friend class ScopedErrorIgnorer; | 475 friend class ScopedErrorIgnorer; |
| 470 | 476 |
| 471 // Statement accesses StatementRef which we don't want to expose to everybody | 477 // Statement accesses StatementRef which we don't want to expose to everybody |
| 472 // (they should go through Statement). | 478 // (they should go through Statement). |
| 473 friend class Statement; | 479 friend class Statement; |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 703 // Source for timing information, provided to allow tests to inject time | 709 // Source for timing information, provided to allow tests to inject time |
| 704 // changes. | 710 // changes. |
| 705 scoped_ptr<TimeSource> clock_; | 711 scoped_ptr<TimeSource> clock_; |
| 706 | 712 |
| 707 DISALLOW_COPY_AND_ASSIGN(Connection); | 713 DISALLOW_COPY_AND_ASSIGN(Connection); |
| 708 }; | 714 }; |
| 709 | 715 |
| 710 } // namespace sql | 716 } // namespace sql |
| 711 | 717 |
| 712 #endif // SQL_CONNECTION_H_ | 718 #endif // SQL_CONNECTION_H_ |
| OLD | NEW |