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

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

Issue 9460047: sync: remove use of protobuf extensions in protocol to reduce static init overhead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fred's review Created 8 years, 9 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 | Annotate | Revision Log
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/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 #include <limits> 9 #include <limits>
10 10
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 const void* data, int size) { 562 const void* data, int size) {
563 sync_pb::EntitySpecifics specifics; 563 sync_pb::EntitySpecifics specifics;
564 if (!specifics.ParseFromArray(data, size)) 564 if (!specifics.ParseFromArray(data, size))
565 return syncable::UNSPECIFIED; 565 return syncable::UNSPECIFIED;
566 return syncable::GetModelTypeFromSpecifics(specifics); 566 return syncable::GetModelTypeFromSpecifics(specifics);
567 } 567 }
568 568
569 // static 569 // static
570 string DirectoryBackingStore::ModelTypeEnumToModelId(ModelType model_type) { 570 string DirectoryBackingStore::ModelTypeEnumToModelId(ModelType model_type) {
571 sync_pb::EntitySpecifics specifics; 571 sync_pb::EntitySpecifics specifics;
572 syncable::AddDefaultExtensionValue(model_type, &specifics); 572 syncable::AddDefaultFieldValue(model_type, &specifics);
573 return specifics.SerializeAsString(); 573 return specifics.SerializeAsString();
574 } 574 }
575 575
576 // static 576 // static
577 std::string DirectoryBackingStore::GenerateCacheGUID() { 577 std::string DirectoryBackingStore::GenerateCacheGUID() {
578 // Generate a GUID with 128 bits of randomness. 578 // Generate a GUID with 128 bits of randomness.
579 const int kGuidBytes = 128 / 8; 579 const int kGuidBytes = 128 / 8;
580 std::string guid; 580 std::string guid;
581 base::Base64Encode(base::RandBytesAsString(kGuidBytes), &guid); 581 base::Base64Encode(base::RandBytesAsString(kGuidBytes), &guid);
582 return guid; 582 return guid;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 sync_pb::EntitySpecifics* mutable_new_value) { 673 sync_pb::EntitySpecifics* mutable_new_value) {
674 // Extract data from the column trio we expect. 674 // Extract data from the column trio we expect.
675 bool old_is_bookmark_object = old_value_query->ColumnBool(old_value_column); 675 bool old_is_bookmark_object = old_value_query->ColumnBool(old_value_column);
676 std::string old_url = old_value_query->ColumnString(old_value_column + 1); 676 std::string old_url = old_value_query->ColumnString(old_value_column + 1);
677 std::string old_favicon; 677 std::string old_favicon;
678 old_value_query->ColumnBlobAsString(old_value_column + 2, &old_favicon); 678 old_value_query->ColumnBlobAsString(old_value_column + 2, &old_favicon);
679 bool old_is_dir = old_value_query->ColumnBool(old_value_column + 3); 679 bool old_is_dir = old_value_query->ColumnBool(old_value_column + 3);
680 680
681 if (old_is_bookmark_object) { 681 if (old_is_bookmark_object) {
682 sync_pb::BookmarkSpecifics* bookmark_data = 682 sync_pb::BookmarkSpecifics* bookmark_data =
683 mutable_new_value->MutableExtension(sync_pb::bookmark); 683 mutable_new_value->mutable_bookmark();
684 if (!old_is_dir) { 684 if (!old_is_dir) {
685 bookmark_data->set_url(old_url); 685 bookmark_data->set_url(old_url);
686 bookmark_data->set_favicon(old_favicon); 686 bookmark_data->set_favicon(old_favicon);
687 } 687 }
688 } 688 }
689 } 689 }
690 690
691 } // namespace 691 } // namespace
692 692
693 bool DirectoryBackingStore::MigrateVersion68To69() { 693 bool DirectoryBackingStore::MigrateVersion68To69() {
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 while (query.Step()) { 877 while (query.Step()) {
878 ModelType type = ModelIdToModelTypeEnum(query.ColumnBlob(0), 878 ModelType type = ModelIdToModelTypeEnum(query.ColumnBlob(0),
879 query.ColumnByteLength(0)); 879 query.ColumnByteLength(0));
880 if (type != UNSPECIFIED) { 880 if (type != UNSPECIFIED) {
881 // Set the |timestamp_token_for_migration| on a new 881 // Set the |timestamp_token_for_migration| on a new
882 // DataTypeProgressMarker, using the old value of last_download_timestamp. 882 // DataTypeProgressMarker, using the old value of last_download_timestamp.
883 // The server will turn this into a real token on our behalf the next 883 // The server will turn this into a real token on our behalf the next
884 // time we check for updates. 884 // time we check for updates.
885 sync_pb::DataTypeProgressMarker progress_marker; 885 sync_pb::DataTypeProgressMarker progress_marker;
886 progress_marker.set_data_type_id( 886 progress_marker.set_data_type_id(
887 GetExtensionFieldNumberFromModelType(type)); 887 GetSpecificsFieldNumberFromModelType(type));
888 progress_marker.set_timestamp_token_for_migration(query.ColumnInt64(1)); 888 progress_marker.set_timestamp_token_for_migration(query.ColumnInt64(1));
889 std::string progress_blob; 889 std::string progress_blob;
890 progress_marker.SerializeToString(&progress_blob); 890 progress_marker.SerializeToString(&progress_blob);
891 891
892 update.BindBlob(0, query.ColumnBlob(0), query.ColumnByteLength(0)); 892 update.BindBlob(0, query.ColumnBlob(0), query.ColumnByteLength(0));
893 update.BindBlob(1, progress_blob.data(), progress_blob.length()); 893 update.BindBlob(1, progress_blob.data(), progress_blob.length());
894 update.BindBool(2, query.ColumnBool(2)); 894 update.BindBool(2, query.ColumnBool(2));
895 if (!update.Run()) 895 if (!update.Run())
896 return false; 896 return false;
897 update.Reset(); 897 update.Reset();
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 "id TEXT primary key, " 1092 "id TEXT primary key, "
1093 "name TEXT, " 1093 "name TEXT, "
1094 "store_birthday TEXT, " 1094 "store_birthday TEXT, "
1095 "db_create_version TEXT, " 1095 "db_create_version TEXT, "
1096 "db_create_time INT, " 1096 "db_create_time INT, "
1097 "next_id INT default -2, " 1097 "next_id INT default -2, "
1098 "cache_guid TEXT )"); 1098 "cache_guid TEXT )");
1099 return db_.Execute(query.c_str()); 1099 return db_.Execute(query.c_str());
1100 } 1100 }
1101 } // namespace syncable 1101 } // namespace syncable
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698