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

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

Issue 1136953013: Sync: Change Local IDs to GUID based to avoid ID collision (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed setting KERNEL_SHARE_INFO_DIRTY when incrementing transaction version Created 5 years, 7 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 284
285 if (!DeleteEntries(DELETE_JOURNAL_TABLE, snapshot.delete_journals_to_purge)) 285 if (!DeleteEntries(DELETE_JOURNAL_TABLE, snapshot.delete_journals_to_purge))
286 return false; 286 return false;
287 287
288 if (save_info) { 288 if (save_info) {
289 const Directory::PersistedKernelInfo& info = snapshot.kernel_info; 289 const Directory::PersistedKernelInfo& info = snapshot.kernel_info;
290 sql::Statement s1(db_->GetCachedStatement( 290 sql::Statement s1(db_->GetCachedStatement(
291 SQL_FROM_HERE, 291 SQL_FROM_HERE,
292 "UPDATE share_info " 292 "UPDATE share_info "
293 "SET store_birthday = ?, " 293 "SET store_birthday = ?, "
294 "next_id = ?, "
295 "bag_of_chips = ?")); 294 "bag_of_chips = ?"));
296 s1.BindString(0, info.store_birthday); 295 s1.BindString(0, info.store_birthday);
297 s1.BindInt64(1, info.next_id); 296 s1.BindBlob(1, info.bag_of_chips.data(), info.bag_of_chips.size());
298 s1.BindBlob(2, info.bag_of_chips.data(), info.bag_of_chips.size());
299 297
300 if (!s1.Run()) 298 if (!s1.Run())
301 return false; 299 return false;
302 DCHECK_EQ(db_->GetLastChangeCount(), 1); 300 DCHECK_EQ(db_->GetLastChangeCount(), 1);
303 301
304 sql::Statement s2(db_->GetCachedStatement( 302 sql::Statement s2(db_->GetCachedStatement(
305 SQL_FROM_HERE, 303 SQL_FROM_HERE,
306 "INSERT OR REPLACE " 304 "INSERT OR REPLACE "
307 "INTO models (model_id, " 305 "INTO models (model_id, "
308 "progress_marker, " 306 "progress_marker, "
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 SafeDropTable("temp_share_info"); 566 SafeDropTable("temp_share_info");
569 if (!CreateShareInfoTable(true)) 567 if (!CreateShareInfoTable(true))
570 return false; 568 return false;
571 569
572 // TODO(rlarocque, 124140): Remove notification_state. 570 // TODO(rlarocque, 124140): Remove notification_state.
573 if (!db_->Execute( 571 if (!db_->Execute(
574 "INSERT INTO temp_share_info (id, name, store_birthday, " 572 "INSERT INTO temp_share_info (id, name, store_birthday, "
575 "db_create_version, db_create_time, next_id, cache_guid," 573 "db_create_version, db_create_time, next_id, cache_guid,"
576 "notification_state, bag_of_chips) " 574 "notification_state, bag_of_chips) "
577 "SELECT id, name, store_birthday, db_create_version, " 575 "SELECT id, name, store_birthday, db_create_version, "
578 "db_create_time, next_id, cache_guid, notification_state, " 576 "db_create_time, next_id, cache_guid, notification_state, "
maniscalco 2015/05/14 15:54:20 Just wanted to confirm that it's OK to leave this
579 "bag_of_chips " 577 "bag_of_chips "
580 "FROM share_info")) 578 "FROM share_info"))
581 return false; 579 return false;
582 580
583 SafeDropTable("share_info"); 581 SafeDropTable("share_info");
584 if (!db_->Execute("ALTER TABLE temp_share_info RENAME TO share_info")) 582 if (!db_->Execute("ALTER TABLE temp_share_info RENAME TO share_info"))
585 return false; 583 return false;
586 584
587 needs_column_refresh_ = false; 585 needs_column_refresh_ = false;
588 return true; 586 return true;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 // A null kernel is evidence of external data corruption. 637 // A null kernel is evidence of external data corruption.
640 if (!kernel) 638 if (!kernel)
641 return false; 639 return false;
642 delete_journals->insert(kernel.release()); 640 delete_journals->insert(kernel.release());
643 } 641 }
644 return s.Succeeded(); 642 return s.Succeeded();
645 } 643 }
646 644
647 bool DirectoryBackingStore::LoadInfo(Directory::KernelLoadInfo* info) { 645 bool DirectoryBackingStore::LoadInfo(Directory::KernelLoadInfo* info) {
648 { 646 {
649 sql::Statement s( 647 sql::Statement s(db_->GetUniqueStatement(
650 db_->GetUniqueStatement( 648 "SELECT store_birthday, cache_guid, bag_of_chips "
651 "SELECT store_birthday, next_id, cache_guid, bag_of_chips " 649 "FROM share_info"));
652 "FROM share_info"));
653 if (!s.Step()) 650 if (!s.Step())
654 return false; 651 return false;
655 652
656 info->kernel_info.store_birthday = s.ColumnString(0); 653 info->kernel_info.store_birthday = s.ColumnString(0);
657 info->kernel_info.next_id = s.ColumnInt64(1); 654 info->cache_guid = s.ColumnString(1);
658 info->cache_guid = s.ColumnString(2); 655 s.ColumnBlobAsString(2, &(info->kernel_info.bag_of_chips));
659 s.ColumnBlobAsString(3, &(info->kernel_info.bag_of_chips));
660 656
661 // Verify there was only one row returned. 657 // Verify there was only one row returned.
662 DCHECK(!s.Step()); 658 DCHECK(!s.Step());
663 DCHECK(s.Succeeded()); 659 DCHECK(s.Succeeded());
664 } 660 }
665 661
666 { 662 {
667 sql::Statement s( 663 sql::Statement s(
668 db_->GetUniqueStatement( 664 db_->GetUniqueStatement(
669 "SELECT model_id, progress_marker, " 665 "SELECT model_id, progress_marker, "
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 DCHECK(CalledOnValidThread()); 1673 DCHECK(CalledOnValidThread());
1678 DCHECK(!catastrophic_error_handler.is_null()); 1674 DCHECK(!catastrophic_error_handler.is_null());
1679 catastrophic_error_handler_ = catastrophic_error_handler; 1675 catastrophic_error_handler_ = catastrophic_error_handler;
1680 sql::Connection::ErrorCallback error_callback = 1676 sql::Connection::ErrorCallback error_callback =
1681 base::Bind(&OnSqliteError, catastrophic_error_handler_); 1677 base::Bind(&OnSqliteError, catastrophic_error_handler_);
1682 db_->set_error_callback(error_callback); 1678 db_->set_error_callback(error_callback);
1683 } 1679 }
1684 1680
1685 } // namespace syncable 1681 } // namespace syncable
1686 } // namespace syncer 1682 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698