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

Side by Side Diff: sql/connection.cc

Issue 2225333003: Recreate the WebData database on a catastrophic SQL error (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: shess@' comments Created 4 years, 4 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
« no previous file with comments | « components/webdata/common/web_database_service.cc ('k') | no next file » | 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 #include "sql/connection.h" 5 #include "sql/connection.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 1726
1727 // http://www.sqlite.org/pragma.html#pragma_journal_mode 1727 // http://www.sqlite.org/pragma.html#pragma_journal_mode
1728 // DELETE (default) - delete -journal file to commit. 1728 // DELETE (default) - delete -journal file to commit.
1729 // TRUNCATE - truncate -journal file to commit. 1729 // TRUNCATE - truncate -journal file to commit.
1730 // PERSIST - zero out header of -journal file to commit. 1730 // PERSIST - zero out header of -journal file to commit.
1731 // TRUNCATE should be faster than DELETE because it won't need directory 1731 // TRUNCATE should be faster than DELETE because it won't need directory
1732 // changes for each transaction. PERSIST may break the spirit of using 1732 // changes for each transaction. PERSIST may break the spirit of using
1733 // secure_delete. 1733 // secure_delete.
1734 ignore_result(Execute("PRAGMA journal_mode = TRUNCATE")); 1734 ignore_result(Execute("PRAGMA journal_mode = TRUNCATE"));
1735 1735
1736 bool was_poisoned = poisoned_;
1737 if (was_poisoned) {
1738 Close();
1739 if (retry_flag == RETRY_ON_POISON)
1740 return OpenInternal(file_name, NO_RETRY);
1741 return false;
1742 }
Scott Hess - ex-Googler 2016/08/12 21:11:53 I'm going to post you an alternative, once I've fi
1743
1736 const base::TimeDelta kBusyTimeout = 1744 const base::TimeDelta kBusyTimeout =
1737 base::TimeDelta::FromSeconds(kBusyTimeoutSeconds); 1745 base::TimeDelta::FromSeconds(kBusyTimeoutSeconds);
1738 1746
1739 if (page_size_ != 0) { 1747 if (page_size_ != 0) {
1740 // Enforce SQLite restrictions on |page_size_|. 1748 // Enforce SQLite restrictions on |page_size_|.
1741 DCHECK(!(page_size_ & (page_size_ - 1))) 1749 DCHECK(!(page_size_ & (page_size_ - 1)))
1742 << " page_size_ " << page_size_ << " is not a power of two."; 1750 << " page_size_ " << page_size_ << " is not a power of two.";
1743 const int kSqliteMaxPageSize = 32768; // from sqliteLimit.h 1751 const int kSqliteMaxPageSize = 32768; // from sqliteLimit.h
1744 DCHECK_LE(page_size_, kSqliteMaxPageSize); 1752 DCHECK_LE(page_size_, kSqliteMaxPageSize);
1745 const std::string sql = 1753 const std::string sql =
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1974 ignore_result(Execute(kNoWritableSchema)); 1982 ignore_result(Execute(kNoWritableSchema));
1975 1983
1976 return ret; 1984 return ret;
1977 } 1985 }
1978 1986
1979 base::TimeTicks TimeSource::Now() { 1987 base::TimeTicks TimeSource::Now() {
1980 return base::TimeTicks::Now(); 1988 return base::TimeTicks::Now();
1981 } 1989 }
1982 1990
1983 } // namespace sql 1991 } // namespace sql
OLDNEW
« no previous file with comments | « components/webdata/common/web_database_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698