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

Side by Side Diff: sql/connection.h

Issue 1432953002: Revert "[sql] Validate database files before enabling memory-mapping." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | 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) 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>
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 EVENT_CHANGES_AUTOCOMMIT, 197 EVENT_CHANGES_AUTOCOMMIT,
198 198
199 // Number of rows changed by statements in transactions. 199 // Number of rows changed by statements in transactions.
200 EVENT_CHANGES, 200 EVENT_CHANGES,
201 201
202 // Count actual SQLite transaction statements (not including nesting). 202 // Count actual SQLite transaction statements (not including nesting).
203 EVENT_BEGIN, 203 EVENT_BEGIN,
204 EVENT_COMMIT, 204 EVENT_COMMIT,
205 EVENT_ROLLBACK, 205 EVENT_ROLLBACK,
206 206
207 // Track success and failure in GetAppropriateMmapSize().
208 // GetAppropriateMmapSize() should record at most one of these per run. The
209 // case of mapping everything is not recorded.
210 EVENT_MMAP_META_MISSING, // No meta table present.
211 EVENT_MMAP_META_FAILURE_READ, // Failed reading meta table.
212 EVENT_MMAP_META_FAILURE_UPDATE, // Failed updating meta table.
213 EVENT_MMAP_VFS_FAILURE, // Failed to access VFS.
214 EVENT_MMAP_FAILED, // Failure from past run.
215 EVENT_MMAP_FAILED_NEW, // Read error in this run.
216 EVENT_MMAP_SUCCESS_NEW, // Read to EOF in this run.
217 EVENT_MMAP_SUCCESS_PARTIAL, // Read but did not reach EOF.
218 EVENT_MMAP_SUCCESS_NO_PROGRESS, // Read quota exhausted.
219
220 // Leave this at the end. 207 // Leave this at the end.
221 // TODO(shess): |EVENT_MAX| causes compile fail on Windows. 208 // TODO(shess): |EVENT_MAX| causes compile fail on Windows.
222 EVENT_MAX_VALUE 209 EVENT_MAX_VALUE
223 }; 210 };
224 void RecordEvent(Events event, size_t count); 211 void RecordEvent(Events event, size_t count);
225 void RecordOneEvent(Events event) { 212 void RecordOneEvent(Events event) {
226 RecordEvent(event, 1); 213 RecordEvent(event, 1);
227 } 214 }
228 215
229 // Run "PRAGMA integrity_check" and post each line of 216 // Run "PRAGMA integrity_check" and post each line of
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 // database is razed or recovered, or if the diagnostic code adds new 682 // database is razed or recovered, or if the diagnostic code adds new
696 // capabilities. 683 // capabilities.
697 bool RegisterIntentToUpload() const; 684 bool RegisterIntentToUpload() const;
698 685
699 // Helper to collect diagnostic info for a corrupt database. 686 // Helper to collect diagnostic info for a corrupt database.
700 std::string CollectCorruptionInfo(); 687 std::string CollectCorruptionInfo();
701 688
702 // Helper to collect diagnostic info for errors. 689 // Helper to collect diagnostic info for errors.
703 std::string CollectErrorInfo(int error, Statement* stmt) const; 690 std::string CollectErrorInfo(int error, Statement* stmt) const;
704 691
705 // Calculates a value appropriate to pass to "PRAGMA mmap_size = ". So errors
706 // can make it unsafe to map a file, so the file is read using regular I/O,
707 // with any errors causing 0 (don't map anything) to be returned. If the
708 // entire file is read without error, a large value is returned which will
709 // allow the entire file to be mapped in most cases.
710 //
711 // Results are recorded in the database's meta table for future reference, so
712 // the file should only be read through once.
713 size_t GetAppropriateMmapSize();
714
715 // The actual sqlite database. Will be NULL before Init has been called or if 692 // The actual sqlite database. Will be NULL before Init has been called or if
716 // Init resulted in an error. 693 // Init resulted in an error.
717 sqlite3* db_; 694 sqlite3* db_;
718 695
719 // Parameters we'll configure in sqlite before doing anything else. Zero means 696 // Parameters we'll configure in sqlite before doing anything else. Zero means
720 // use the default value. 697 // use the default value.
721 int page_size_; 698 int page_size_;
722 int cache_size_; 699 int cache_size_;
723 bool exclusive_locking_; 700 bool exclusive_locking_;
724 bool restrict_to_user_; 701 bool restrict_to_user_;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 // Source for timing information, provided to allow tests to inject time 765 // Source for timing information, provided to allow tests to inject time
789 // changes. 766 // changes.
790 scoped_ptr<TimeSource> clock_; 767 scoped_ptr<TimeSource> clock_;
791 768
792 DISALLOW_COPY_AND_ASSIGN(Connection); 769 DISALLOW_COPY_AND_ASSIGN(Connection);
793 }; 770 };
794 771
795 } // namespace sql 772 } // namespace sql
796 773
797 #endif // SQL_CONNECTION_H_ 774 #endif // SQL_CONNECTION_H_
OLDNEW
« no previous file with comments | « no previous file | sql/connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698