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

Side by Side Diff: sync/syncable/directory_backing_store.cc

Issue 1082423002: [Sync] Make DirectoryBackingStore's db_ private. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "sync/syncable/directory_backing_store.h" 5 #include "sync/syncable/directory_backing_store.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include <limits> 9 #include <limits>
10 10
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 DirectoryBackingStore::DirectoryBackingStore(const string& dir_name) 199 DirectoryBackingStore::DirectoryBackingStore(const string& dir_name)
200 : dir_name_(dir_name), 200 : dir_name_(dir_name),
201 database_page_size_(IsSyncBackingDatabase32KEnabled() ? 32768 : 4096), 201 database_page_size_(IsSyncBackingDatabase32KEnabled() ? 32768 : 4096),
202 needs_column_refresh_(false) { 202 needs_column_refresh_(false) {
203 DCHECK(base::ThreadTaskRunnerHandle::IsSet()); 203 DCHECK(base::ThreadTaskRunnerHandle::IsSet());
204 ResetAndCreateConnection(); 204 ResetAndCreateConnection();
205 } 205 }
206 206
207 DirectoryBackingStore::DirectoryBackingStore(const string& dir_name, 207 DirectoryBackingStore::DirectoryBackingStore(const string& dir_name,
208 sql::Connection* db) 208 sql::Connection* db)
209 : db_(db), 209 : dir_name_(dir_name),
210 dir_name_(dir_name),
211 database_page_size_(IsSyncBackingDatabase32KEnabled() ? 32768 : 4096), 210 database_page_size_(IsSyncBackingDatabase32KEnabled() ? 32768 : 4096),
211 db_(db),
212 needs_column_refresh_(false) { 212 needs_column_refresh_(false) {
213 DCHECK(base::ThreadTaskRunnerHandle::IsSet()); 213 DCHECK(base::ThreadTaskRunnerHandle::IsSet());
214 } 214 }
215 215
216 DirectoryBackingStore::~DirectoryBackingStore() { 216 DirectoryBackingStore::~DirectoryBackingStore() {
217 } 217 }
218 218
219 bool DirectoryBackingStore::DeleteEntries(EntryTable from, 219 bool DirectoryBackingStore::DeleteEntries(EntryTable from,
220 const MetahandleSet& handles) { 220 const MetahandleSet& handles) {
221 if (handles.empty()) 221 if (handles.empty())
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 if (!s2.Run()) 327 if (!s2.Run())
328 return false; 328 return false;
329 DCHECK_EQ(db_->GetLastChangeCount(), 1); 329 DCHECK_EQ(db_->GetLastChangeCount(), 1);
330 s2.Reset(true); 330 s2.Reset(true);
331 } 331 }
332 } 332 }
333 333
334 return transaction.Commit(); 334 return transaction.Commit();
335 } 335 }
336 336
337 sql::Connection* DirectoryBackingStore::db() {
338 return db_.get();
339 }
340
341 bool DirectoryBackingStore::IsOpen() const {
342 return db_->is_open();
343 }
344
345 bool DirectoryBackingStore::Open(const base::FilePath& path) {
346 DCHECK(!db_->is_open());
347 return db_->Open(path);
348 }
349
350 bool DirectoryBackingStore::OpenInMemory() {
351 DCHECK(!db_->is_open());
352 return db_->OpenInMemory();
353 }
354
337 bool DirectoryBackingStore::InitializeTables() { 355 bool DirectoryBackingStore::InitializeTables() {
338 int page_size = 0; 356 int page_size = 0;
339 if (IsSyncBackingDatabase32KEnabled() && GetDatabasePageSize(&page_size) && 357 if (IsSyncBackingDatabase32KEnabled() && GetDatabasePageSize(&page_size) &&
340 page_size == 4096) { 358 page_size == 4096) {
341 IncreasePageSizeTo32K(); 359 IncreasePageSizeTo32K();
342 } 360 }
343 sql::Transaction transaction(db_.get()); 361 sql::Transaction transaction(db_.get());
344 if (!transaction.Begin()) 362 if (!transaction.Begin())
345 return false; 363 return false;
346 364
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 DCHECK(CalledOnValidThread()); 1685 DCHECK(CalledOnValidThread());
1668 DCHECK(!catastrophic_error_handler.is_null()); 1686 DCHECK(!catastrophic_error_handler.is_null());
1669 catastrophic_error_handler_ = catastrophic_error_handler; 1687 catastrophic_error_handler_ = catastrophic_error_handler;
1670 sql::Connection::ErrorCallback error_callback = 1688 sql::Connection::ErrorCallback error_callback =
1671 base::Bind(&OnSqliteError, catastrophic_error_handler_); 1689 base::Bind(&OnSqliteError, catastrophic_error_handler_);
1672 db_->set_error_callback(error_callback); 1690 db_->set_error_callback(error_callback);
1673 } 1691 }
1674 1692
1675 } // namespace syncable 1693 } // namespace syncable
1676 } // namespace syncer 1694 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698