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

Side by Side Diff: chrome/browser/net/sqlite_server_bound_cert_store.cc

Issue 10824008: Annotate calls to SQLite functions - they have to be executed on a thread allowing IO access. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | « no previous file | chrome/browser/password_manager/password_store_factory.cc » ('j') | 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 "chrome/browser/net/sqlite_server_bound_cert_store.h" 5 #include "chrome/browser/net/sqlite_server_bound_cert_store.h"
6 6
7 #include <list> 7 #include <list>
8 #include <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 return true; 152 return true;
153 } 153 }
154 154
155 } // namespace 155 } // namespace
156 156
157 bool SQLiteServerBoundCertStore::Backend::Load( 157 bool SQLiteServerBoundCertStore::Backend::Load(
158 std::vector<net::DefaultServerBoundCertStore::ServerBoundCert*>* certs) { 158 std::vector<net::DefaultServerBoundCertStore::ServerBoundCert*>* certs) {
159 // This function should be called only once per instance. 159 // This function should be called only once per instance.
160 DCHECK(!db_.get()); 160 DCHECK(!db_.get());
161 161
162 // TODO(paivanof@gmail.com): We do a lot of disk access in this function,
163 // thus we do an exception to allow IO on the UI thread. This code will be
164 // moved to the DB thread as part of http://crbug.com/89665.
165 base::ThreadRestrictions::ScopedAllowIO allow_io;
166
162 // Ensure the parent directory for storing certs is created before reading 167 // Ensure the parent directory for storing certs is created before reading
163 // from it. We make an exception to allow IO on the UI thread here because 168 // from it.
164 // we are going to disk anyway in db_->Open. (This code will be moved to the 169 const FilePath dir = path_.DirName();
165 // DB thread as part of http://crbug.com/52909.) 170 if (!file_util::PathExists(dir) && !file_util::CreateDirectory(dir))
166 { 171 return false;
167 base::ThreadRestrictions::ScopedAllowIO allow_io;
168 const FilePath dir = path_.DirName();
169 if (!file_util::PathExists(dir) && !file_util::CreateDirectory(dir))
170 return false;
171 }
172 172
173 db_.reset(new sql::Connection); 173 db_.reset(new sql::Connection);
174 if (!db_->Open(path_)) { 174 if (!db_->Open(path_)) {
175 NOTREACHED() << "Unable to open cert DB."; 175 NOTREACHED() << "Unable to open cert DB.";
176 db_.reset(); 176 db_.reset();
177 return false; 177 return false;
178 } 178 }
179 179
180 if (!EnsureDatabaseVersion() || !InitTable(db_.get())) { 180 if (!EnsureDatabaseVersion() || !InitTable(db_.get())) {
181 NOTREACHED() << "Unable to open cert DB."; 181 NOTREACHED() << "Unable to open cert DB.";
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 } 561 }
562 562
563 SQLiteServerBoundCertStore::~SQLiteServerBoundCertStore() { 563 SQLiteServerBoundCertStore::~SQLiteServerBoundCertStore() {
564 if (backend_.get()) { 564 if (backend_.get()) {
565 backend_->Close(); 565 backend_->Close();
566 // Release our reference, it will probably still have a reference if the 566 // Release our reference, it will probably still have a reference if the
567 // background thread has not run Close() yet. 567 // background thread has not run Close() yet.
568 backend_ = NULL; 568 backend_ = NULL;
569 } 569 }
570 } 570 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/password_manager/password_store_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698