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

Side by Side Diff: sql/connection.h

Issue 1327063002: [tracing] Add sqlite memory statistics to tracing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 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
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 <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
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:
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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 // running the following statement at a sqlite3 command-line: 458 // running the following statement at a sqlite3 command-line:
458 // SELECT type, name, tbl_name, sql FROM sqlite_master ORDER BY 1, 2, 3, 4; 459 // SELECT type, name, tbl_name, sql FROM sqlite_master ORDER BY 1, 2, 3, 4;
459 std::string GetSchema() const; 460 std::string GetSchema() const;
460 461
461 // Clients which provide an error_callback don't see the 462 // Clients which provide an error_callback don't see the
462 // error-handling at the end of OnSqliteError(). Expose to allow 463 // error-handling at the end of OnSqliteError(). Expose to allow
463 // those clients to work appropriately with ScopedErrorIgnorer in 464 // those clients to work appropriately with ScopedErrorIgnorer in
464 // tests. 465 // tests.
465 static bool ShouldIgnoreSqliteError(int error); 466 static bool ShouldIgnoreSqliteError(int error);
466 467
468 // base::trace_event::MemoryDumpProvider implementation.
469 bool OnMemoryDump(
470 const base::trace_event::MemoryDumpArgs& args,
471 base::trace_event::ProcessMemoryDump* process_memory_dump) override;
472
467 private: 473 private:
468 // For recovery module. 474 // For recovery module.
469 friend class Recovery; 475 friend class Recovery;
470 476
471 // Allow test-support code to set/reset error ignorer. 477 // Allow test-support code to set/reset error ignorer.
472 friend class ScopedErrorIgnorer; 478 friend class ScopedErrorIgnorer;
473 479
474 // Statement accesses StatementRef which we don't want to expose to everybody 480 // Statement accesses StatementRef which we don't want to expose to everybody
475 // (they should go through Statement). 481 // (they should go through Statement).
476 friend class Statement; 482 friend class Statement;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 // Source for timing information, provided to allow tests to inject time 729 // Source for timing information, provided to allow tests to inject time
724 // changes. 730 // changes.
725 scoped_ptr<TimeSource> clock_; 731 scoped_ptr<TimeSource> clock_;
726 732
727 DISALLOW_COPY_AND_ASSIGN(Connection); 733 DISALLOW_COPY_AND_ASSIGN(Connection);
728 }; 734 };
729 735
730 } // namespace sql 736 } // namespace sql
731 737
732 #endif // SQL_CONNECTION_H_ 738 #endif // SQL_CONNECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698