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

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

Issue 429003: Final part of PathString cleanup. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/sync/syncable/directory_backing_store.h" 5 #include "chrome/browser/sync/syncable/directory_backing_store.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_MACOSX) 9 #if defined(OS_MACOSX)
10 #include <CoreFoundation/CoreFoundation.h> 10 #include <CoreFoundation/CoreFoundation.h>
11 #endif 11 #endif
12 12
13 #include <string>
14
15 #include "base/hash_tables.h" 13 #include "base/hash_tables.h"
16 #include "base/logging.h" 14 #include "base/logging.h"
17 #include "chrome/browser/sync/protocol/service_constants.h" 15 #include "chrome/browser/sync/protocol/service_constants.h"
18 #include "chrome/browser/sync/syncable/syncable-inl.h" 16 #include "chrome/browser/sync/syncable/syncable-inl.h"
19 #include "chrome/browser/sync/syncable/syncable_columns.h" 17 #include "chrome/browser/sync/syncable/syncable_columns.h"
20 #include "chrome/browser/sync/util/crypto_helpers.h" 18 #include "chrome/browser/sync/util/crypto_helpers.h"
21 #include "chrome/browser/sync/util/path_helpers.h" 19 #include "chrome/browser/sync/util/path_helpers.h"
22 #include "chrome/browser/sync/util/query_helpers.h" 20 #include "chrome/browser/sync/util/query_helpers.h"
23 #include "third_party/sqlite/preprocessed/sqlite3.h" 21 #include "third_party/sqlite/preprocessed/sqlite3.h"
24 22
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 query.push_back(' '); 184 query.push_back(' ');
187 query.append(column->spec); 185 query.append(column->spec);
188 } 186 }
189 query.push_back(')'); 187 query.push_back(')');
190 return query; 188 return query;
191 } 189 }
192 190
193 /////////////////////////////////////////////////////////////////////////////// 191 ///////////////////////////////////////////////////////////////////////////////
194 // DirectoryBackingStore implementation. 192 // DirectoryBackingStore implementation.
195 193
196 DirectoryBackingStore::DirectoryBackingStore(const PathString& dir_name, 194 DirectoryBackingStore::DirectoryBackingStore(const string& dir_name,
197 const FilePath& backing_filepath) 195 const FilePath& backing_filepath)
198 : load_dbhandle_(NULL), 196 : load_dbhandle_(NULL),
199 save_dbhandle_(NULL), 197 save_dbhandle_(NULL),
200 dir_name_(dir_name), 198 dir_name_(dir_name),
201 backing_filepath_(backing_filepath) { 199 backing_filepath_(backing_filepath) {
202 } 200 }
203 201
204 DirectoryBackingStore::~DirectoryBackingStore() { 202 DirectoryBackingStore::~DirectoryBackingStore() {
205 if (NULL != load_dbhandle_) { 203 if (NULL != load_dbhandle_) {
206 sqlite3_close(load_dbhandle_); 204 sqlite3_close(load_dbhandle_);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 if (se.healthy()) { 326 if (se.healthy()) {
329 DropAllTables(); 327 DropAllTables();
330 se.set_result(CreateTables()); 328 se.set_result(CreateTables());
331 } 329 }
332 } 330 }
333 if (SQLITE_DONE == se.result()) { 331 if (SQLITE_DONE == se.result()) {
334 { 332 {
335 ScopedStatement statement(PrepareQuery(load_dbhandle_, 333 ScopedStatement statement(PrepareQuery(load_dbhandle_,
336 "SELECT db_create_version, db_create_time FROM share_info")); 334 "SELECT db_create_version, db_create_time FROM share_info"));
337 CHECK(SQLITE_ROW == sqlite3_step(statement.get())); 335 CHECK(SQLITE_ROW == sqlite3_step(statement.get()));
338 PathString db_create_version; 336 string db_create_version;
339 int db_create_time; 337 int db_create_time;
340 GetColumn(statement.get(), 0, &db_create_version); 338 GetColumn(statement.get(), 0, &db_create_version);
341 GetColumn(statement.get(), 1, &db_create_time); 339 GetColumn(statement.get(), 1, &db_create_time);
342 statement.reset(0); 340 statement.reset(0);
343 LOG(INFO) << "DB created at " << db_create_time << " by version " << 341 LOG(INFO) << "DB created at " << db_create_time << " by version " <<
344 db_create_version; 342 db_create_version;
345 } 343 }
346 // COMMIT TRANSACTION rolls back on failure. 344 // COMMIT TRANSACTION rolls back on failure.
347 if (SQLITE_DONE == Exec(load_dbhandle_, "COMMIT TRANSACTION")) 345 if (SQLITE_DONE == Exec(load_dbhandle_, "COMMIT TRANSACTION"))
348 return OPENED; 346 return OPENED;
(...skipping 23 matching lines...) Expand all
372 } 370 }
373 } 371 }
374 372
375 void DirectoryBackingStore::LoadExtendedAttributes( 373 void DirectoryBackingStore::LoadExtendedAttributes(
376 ExtendedAttributes* xattrs_bucket) { 374 ExtendedAttributes* xattrs_bucket) {
377 ScopedStatement statement(PrepareQuery(load_dbhandle_, 375 ScopedStatement statement(PrepareQuery(load_dbhandle_,
378 "SELECT metahandle, key, value FROM extended_attributes")); 376 "SELECT metahandle, key, value FROM extended_attributes"));
379 int step_result = sqlite3_step(statement.get()); 377 int step_result = sqlite3_step(statement.get());
380 while (SQLITE_ROW == step_result) { 378 while (SQLITE_ROW == step_result) {
381 int64 metahandle; 379 int64 metahandle;
382 PathString path_string_key; 380 string path_string_key;
383 ExtendedAttributeValue val; 381 ExtendedAttributeValue val;
384 val.is_deleted = false; 382 val.is_deleted = false;
385 GetColumn(statement.get(), 0, &metahandle); 383 GetColumn(statement.get(), 0, &metahandle);
386 GetColumn(statement.get(), 1, &path_string_key); 384 GetColumn(statement.get(), 1, &path_string_key);
387 GetColumn(statement.get(), 2, &(val.value)); 385 GetColumn(statement.get(), 2, &(val.value));
388 ExtendedAttributeKey key(metahandle, path_string_key); 386 ExtendedAttributeKey key(metahandle, path_string_key);
389 xattrs_bucket->insert(std::make_pair(key, val)); 387 xattrs_bucket->insert(std::make_pair(key, val));
390 step_result = sqlite3_step(statement.get()); 388 step_result = sqlite3_step(statement.get());
391 } 389 }
392 CHECK(SQLITE_DONE == step_result); 390 CHECK(SQLITE_DONE == step_result);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 601
604 sqlite3* DirectoryBackingStore::LazyGetSaveHandle() { 602 sqlite3* DirectoryBackingStore::LazyGetSaveHandle() {
605 if (!save_dbhandle_ && !OpenAndConfigureHandleHelper(&save_dbhandle_)) { 603 if (!save_dbhandle_ && !OpenAndConfigureHandleHelper(&save_dbhandle_)) {
606 DCHECK(FALSE) << "Unable to open handle for saving"; 604 DCHECK(FALSE) << "Unable to open handle for saving";
607 return NULL; 605 return NULL;
608 } 606 }
609 return save_dbhandle_; 607 return save_dbhandle_;
610 } 608 }
611 609
612 } // namespace syncable 610 } // namespace syncable
OLDNEW
« no previous file with comments | « chrome/browser/sync/syncable/directory_backing_store.h ('k') | chrome/browser/sync/syncable/syncable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698