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

Side by Side Diff: sql/connection.cc

Issue 8690005: Remove 4 static initializers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cin Created 9 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
« no previous file with comments | « chrome/browser/sync/syncable/directory_backing_store.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string.h> 7 #include <string.h>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "sql/statement.h" 14 #include "sql/statement.h"
15 #include "third_party/sqlite/sqlite3.h" 15 #include "third_party/sqlite/sqlite3.h"
16 16
17 namespace { 17 namespace {
18 18
19 // Spin for up to a second waiting for the lock to clear when setting 19 // Spin for up to a second waiting for the lock to clear when setting
20 // up the database. 20 // up the database.
21 // TODO(shess): Better story on this. http://crbug.com/56559 21 // TODO(shess): Better story on this. http://crbug.com/56559
22 const base::TimeDelta kBusyTimeout = base::TimeDelta::FromSeconds(1); 22 const int kBusyTimeoutSeconds = 1;
23 23
24 class ScopedBusyTimeout { 24 class ScopedBusyTimeout {
25 public: 25 public:
26 explicit ScopedBusyTimeout(sqlite3* db) 26 explicit ScopedBusyTimeout(sqlite3* db)
27 : db_(db) { 27 : db_(db) {
28 } 28 }
29 ~ScopedBusyTimeout() { 29 ~ScopedBusyTimeout() {
30 sqlite3_busy_timeout(db_, 0); 30 sqlite3_busy_timeout(db_, 0);
31 } 31 }
32 32
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // assumptions about who might change things in the database. 366 // assumptions about who might change things in the database.
367 // http://crbug.com/56559 367 // http://crbug.com/56559
368 if (exclusive_locking_) { 368 if (exclusive_locking_) {
369 // TODO(shess): This should probably be a full CHECK(). Code 369 // TODO(shess): This should probably be a full CHECK(). Code
370 // which requests exclusive locking but doesn't get it is almost 370 // which requests exclusive locking but doesn't get it is almost
371 // certain to be ill-tested. 371 // certain to be ill-tested.
372 if (!Execute("PRAGMA locking_mode=EXCLUSIVE")) 372 if (!Execute("PRAGMA locking_mode=EXCLUSIVE"))
373 NOTREACHED() << "Could not set locking mode: " << GetErrorMessage(); 373 NOTREACHED() << "Could not set locking mode: " << GetErrorMessage();
374 } 374 }
375 375
376 const base::TimeDelta kBusyTimeout =
377 base::TimeDelta::FromSeconds(kBusyTimeoutSeconds);
378
376 if (page_size_ != 0) { 379 if (page_size_ != 0) {
377 // Enforce SQLite restrictions on |page_size_|. 380 // Enforce SQLite restrictions on |page_size_|.
378 DCHECK(!(page_size_ & (page_size_ - 1))) 381 DCHECK(!(page_size_ & (page_size_ - 1)))
379 << " page_size_ " << page_size_ << " is not a power of two."; 382 << " page_size_ " << page_size_ << " is not a power of two.";
380 static const int kSqliteMaxPageSize = 32768; // from sqliteLimit.h 383 static const int kSqliteMaxPageSize = 32768; // from sqliteLimit.h
381 DCHECK_LE(page_size_, kSqliteMaxPageSize); 384 DCHECK_LE(page_size_, kSqliteMaxPageSize);
382 const std::string sql = StringPrintf("PRAGMA page_size=%d", page_size_); 385 const std::string sql = StringPrintf("PRAGMA page_size=%d", page_size_);
383 if (!ExecuteWithTimeout(sql.c_str(), kBusyTimeout)) 386 if (!ExecuteWithTimeout(sql.c_str(), kBusyTimeout))
384 NOTREACHED() << "Could not set page size: " << GetErrorMessage(); 387 NOTREACHED() << "Could not set page size: " << GetErrorMessage();
385 } 388 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 434
432 int Connection::OnSqliteError(int err, sql::Statement *stmt) { 435 int Connection::OnSqliteError(int err, sql::Statement *stmt) {
433 if (error_delegate_.get()) 436 if (error_delegate_.get())
434 return error_delegate_->OnError(err, this, stmt); 437 return error_delegate_->OnError(err, this, stmt);
435 // The default handling is to assert on debug and to ignore on release. 438 // The default handling is to assert on debug and to ignore on release.
436 NOTREACHED() << GetErrorMessage(); 439 NOTREACHED() << GetErrorMessage();
437 return err; 440 return err;
438 } 441 }
439 442
440 } // namespace sql 443 } // namespace sql
OLDNEW
« no previous file with comments | « chrome/browser/sync/syncable/directory_backing_store.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698