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

Side by Side Diff: sql/connection.h

Issue 104593010: AppCache: Run a quick integrity check on the sqlite database when opening. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // for SQLite error codes and database version numbers. 143 // for SQLite error codes and database version numbers.
144 void set_histogram_tag(const std::string& tag) { 144 void set_histogram_tag(const std::string& tag) {
145 histogram_tag_ = tag; 145 histogram_tag_ = tag;
146 } 146 }
147 147
148 // Record a sparse UMA histogram sample under 148 // Record a sparse UMA histogram sample under
149 // |name|+"."+|histogram_tag_|. If |histogram_tag_| is empty, no 149 // |name|+"."+|histogram_tag_|. If |histogram_tag_| is empty, no
150 // histogram is recorded. 150 // histogram is recorded.
151 void AddTaggedHistogram(const std::string& name, size_t sample) const; 151 void AddTaggedHistogram(const std::string& name, size_t sample) const;
152 152
153 // Run "PRAGMA integrity_check" and post each line of results into 153 // Run "PRAGMA integrity_check" or "quick_check" and post each line of
154 // |messages|. Returns the success of running the statement - per 154 // results into |messages|. Returns the success of running the
155 // the SQLite documentation, if no errors are found the call should 155 // statement - per the SQLite documentation, if no errors are found the
156 // succeed, and a single value "ok" should be in messages. 156 // call should succeed, and a single value "ok" should be in messages.
157 bool IntegrityCheck(std::vector<std::string>* messages); 157 bool FullIntegrityCheck(std::vector<std::string>* messages)
158 WARN_UNUSED_RESULT;
159 bool QuickIntegrityCheck(std::vector<std::string>* messages)
160 WARN_UNUSED_RESULT;
158 161
159 // Initialization ------------------------------------------------------------ 162 // Initialization ------------------------------------------------------------
160 163
161 // Initializes the SQL connection for the given file, returning true if the 164 // Initializes the SQL connection for the given file, returning true if the
162 // file could be opened. You can call this or OpenInMemory. 165 // file could be opened. You can call this or OpenInMemory.
163 bool Open(const base::FilePath& path) WARN_UNUSED_RESULT; 166 bool Open(const base::FilePath& path) WARN_UNUSED_RESULT;
164 167
165 // Initializes the SQL connection for a temporary in-memory database. There 168 // Initializes the SQL connection for a temporary in-memory database. There
166 // will be no associated file on disk, and the initial database will be 169 // will be no associated file on disk, and the initial database will be
167 // empty. You can call this or Open. 170 // empty. You can call this or Open.
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 WARN_UNUSED_RESULT; 536 WARN_UNUSED_RESULT;
534 537
535 // Internal helper for const functions. Like GetUniqueStatement(), 538 // Internal helper for const functions. Like GetUniqueStatement(),
536 // except the statement is not entered into open_statements_, 539 // except the statement is not entered into open_statements_,
537 // allowing this function to be const. Open statements can block 540 // allowing this function to be const. Open statements can block
538 // closing the database, so only use in cases where the last ref is 541 // closing the database, so only use in cases where the last ref is
539 // released before close could be called (which should always be the 542 // released before close could be called (which should always be the
540 // case for const functions). 543 // case for const functions).
541 scoped_refptr<StatementRef> GetUntrackedStatement(const char* sql) const; 544 scoped_refptr<StatementRef> GetUntrackedStatement(const char* sql) const;
542 545
546 bool IntegrityCheckHelper(
547 const char* pragma_sql,
548 std::vector<std::string>* messages) WARN_UNUSED_RESULT;
549
543 // The actual sqlite database. Will be NULL before Init has been called or if 550 // The actual sqlite database. Will be NULL before Init has been called or if
544 // Init resulted in an error. 551 // Init resulted in an error.
545 sqlite3* db_; 552 sqlite3* db_;
546 553
547 // Parameters we'll configure in sqlite before doing anything else. Zero means 554 // Parameters we'll configure in sqlite before doing anything else. Zero means
548 // use the default value. 555 // use the default value.
549 int page_size_; 556 int page_size_;
550 int cache_size_; 557 int cache_size_;
551 bool exclusive_locking_; 558 bool exclusive_locking_;
552 bool restrict_to_user_; 559 bool restrict_to_user_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 592
586 // Tag for auxiliary histograms. 593 // Tag for auxiliary histograms.
587 std::string histogram_tag_; 594 std::string histogram_tag_;
588 595
589 DISALLOW_COPY_AND_ASSIGN(Connection); 596 DISALLOW_COPY_AND_ASSIGN(Connection);
590 }; 597 };
591 598
592 } // namespace sql 599 } // namespace sql
593 600
594 #endif // SQL_CONNECTION_H_ 601 #endif // SQL_CONNECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698