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 |
| 93 if (canceled_.IsSet()) |
| 94 return; |
| 95 |
93 db_.set_exclusive_locking(); | 96 db_.set_exclusive_locking(); |
94 if (!db_.Open(db_path_)) { | 97 if (!db_.Open(db_path_)) { |
95 canceled_.Set(); | 98 canceled_.Set(); |
96 return; | 99 return; |
97 } | 100 } |
98 | 101 |
99 if (!db_.DoesTableExist(kNetworkActionPredictorTableName)) | 102 if (!db_.DoesTableExist(kNetworkActionPredictorTableName)) |
100 CreateTable(); | 103 CreateTable(); |
101 | 104 |
102 LogDatabaseStats(db_path_, &db_); | 105 LogDatabaseStats(db_path_, &db_); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 bool success = db_.Execute(base::StringPrintf( | 255 bool success = db_.Execute(base::StringPrintf( |
253 "CREATE TABLE %s ( " | 256 "CREATE TABLE %s ( " |
254 "id TEXT PRIMARY KEY, " | 257 "id TEXT PRIMARY KEY, " |
255 "user_text TEXT, " | 258 "user_text TEXT, " |
256 "url TEXT, " | 259 "url TEXT, " |
257 "number_of_hits INTEGER, " | 260 "number_of_hits INTEGER, " |
258 "number_of_misses INTEGER)", kNetworkActionPredictorTableName).c_str()); | 261 "number_of_misses INTEGER)", kNetworkActionPredictorTableName).c_str()); |
259 DCHECK(success) << "Failed to create " << kNetworkActionPredictorTableName | 262 DCHECK(success) << "Failed to create " << kNetworkActionPredictorTableName |
260 << " table."; | 263 << " table."; |
261 } | 264 } |
OLD | NEW |