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

Side by Side Diff: chrome/browser/autocomplete/network_action_predictor_database.cc

Issue 8566018: Cope with a race condition in NetworkActionPredictor and NetworkActionPredictorDB initialization. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_browsertest.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 "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
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698