Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/browser/autocomplete/network_action_predictor_database.h" | 5 #include "chrome/browser/autocomplete/network_action_predictor_database.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 | 82 |
| 83 NetworkActionPredictorDatabase::NetworkActionPredictorDatabase(Profile* profile) | 83 NetworkActionPredictorDatabase::NetworkActionPredictorDatabase(Profile* profile) |
| 84 : db_path_(profile->GetPath().Append(kNetworkActionPredictorDatabaseName)) { | 84 : db_path_(profile->GetPath().Append(kNetworkActionPredictorDatabaseName)) { |
| 85 } | 85 } |
| 86 | 86 |
| 87 NetworkActionPredictorDatabase::~NetworkActionPredictorDatabase() { | 87 NetworkActionPredictorDatabase::~NetworkActionPredictorDatabase() { |
| 88 } | 88 } |
| 89 | 89 |
| 90 void NetworkActionPredictorDatabase::Initialize() { | 90 void NetworkActionPredictorDatabase::Initialize() { |
| 91 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::DB)); | 91 CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::DB)); |
| 92 CHECK(!canceled_.IsSet()); | 92 if (canceled_.IsSet()) |
|
Peter Kasting
2011/11/14 22:49:13
Nit: Looks like your practice elsewhere is to add
| |
| 93 return; | |
| 94 | |
| 93 db_.set_exclusive_locking(); | 95 db_.set_exclusive_locking(); |
| 94 if (!db_.Open(db_path_)) { | 96 if (!db_.Open(db_path_)) { |
| 95 canceled_.Set(); | 97 canceled_.Set(); |
| 96 return; | 98 return; |
| 97 } | 99 } |
| 98 | 100 |
| 99 if (!db_.DoesTableExist(kNetworkActionPredictorTableName)) | 101 if (!db_.DoesTableExist(kNetworkActionPredictorTableName)) |
| 100 CreateTable(); | 102 CreateTable(); |
| 101 | 103 |
| 102 LogDatabaseStats(db_path_, &db_); | 104 LogDatabaseStats(db_path_, &db_); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 bool success = db_.Execute(base::StringPrintf( | 254 bool success = db_.Execute(base::StringPrintf( |
| 253 "CREATE TABLE %s ( " | 255 "CREATE TABLE %s ( " |
| 254 "id TEXT PRIMARY KEY, " | 256 "id TEXT PRIMARY KEY, " |
| 255 "user_text TEXT, " | 257 "user_text TEXT, " |
| 256 "url TEXT, " | 258 "url TEXT, " |
| 257 "number_of_hits INTEGER, " | 259 "number_of_hits INTEGER, " |
| 258 "number_of_misses INTEGER)", kNetworkActionPredictorTableName).c_str()); | 260 "number_of_misses INTEGER)", kNetworkActionPredictorTableName).c_str()); |
| 259 DCHECK(success) << "Failed to create " << kNetworkActionPredictorTableName | 261 DCHECK(success) << "Failed to create " << kNetworkActionPredictorTableName |
| 260 << " table."; | 262 << " table."; |
| 261 } | 263 } |
| OLD | NEW |