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

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

Issue 10795018: [Sync] Remove unneeded 'using syncer::' lines and 'syncer::' scopings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fiix indent 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 | 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 "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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // updating. Returns the number of args bound. 44 // updating. Returns the number of args bound.
45 void BindFields(const EntryKernel& entry, 45 void BindFields(const EntryKernel& entry,
46 sql::Statement* statement) { 46 sql::Statement* statement) {
47 int index = 0; 47 int index = 0;
48 int i = 0; 48 int i = 0;
49 for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) { 49 for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) {
50 statement->BindInt64(index++, entry.ref(static_cast<Int64Field>(i))); 50 statement->BindInt64(index++, entry.ref(static_cast<Int64Field>(i)));
51 } 51 }
52 for ( ; i < TIME_FIELDS_END; ++i) { 52 for ( ; i < TIME_FIELDS_END; ++i) {
53 statement->BindInt64(index++, 53 statement->BindInt64(index++,
54 syncer::TimeToProtoTime( 54 TimeToProtoTime(
55 entry.ref(static_cast<TimeField>(i)))); 55 entry.ref(static_cast<TimeField>(i))));
56 } 56 }
57 for ( ; i < ID_FIELDS_END; ++i) { 57 for ( ; i < ID_FIELDS_END; ++i) {
58 statement->BindString(index++, entry.ref(static_cast<IdField>(i)).s_); 58 statement->BindString(index++, entry.ref(static_cast<IdField>(i)).s_);
59 } 59 }
60 for ( ; i < BIT_FIELDS_END; ++i) { 60 for ( ; i < BIT_FIELDS_END; ++i) {
61 statement->BindInt(index++, entry.ref(static_cast<BitField>(i))); 61 statement->BindInt(index++, entry.ref(static_cast<BitField>(i)));
62 } 62 }
63 for ( ; i < STRING_FIELDS_END; ++i) { 63 for ( ; i < STRING_FIELDS_END; ++i) {
64 statement->BindString(index++, entry.ref(static_cast<StringField>(i))); 64 statement->BindString(index++, entry.ref(static_cast<StringField>(i)));
65 } 65 }
66 std::string temp; 66 std::string temp;
67 for ( ; i < PROTO_FIELDS_END; ++i) { 67 for ( ; i < PROTO_FIELDS_END; ++i) {
68 entry.ref(static_cast<ProtoField>(i)).SerializeToString(&temp); 68 entry.ref(static_cast<ProtoField>(i)).SerializeToString(&temp);
69 statement->BindBlob(index++, temp.data(), temp.length()); 69 statement->BindBlob(index++, temp.data(), temp.length());
70 } 70 }
71 } 71 }
72 72
73 // The caller owns the returned EntryKernel*. Assumes the statement currently 73 // The caller owns the returned EntryKernel*. Assumes the statement currently
74 // points to a valid row in the metas table. 74 // points to a valid row in the metas table.
75 EntryKernel* UnpackEntry(sql::Statement* statement) { 75 EntryKernel* UnpackEntry(sql::Statement* statement) {
76 EntryKernel* kernel = new EntryKernel(); 76 EntryKernel* kernel = new EntryKernel();
77 DCHECK_EQ(statement->ColumnCount(), static_cast<int>(FIELD_COUNT)); 77 DCHECK_EQ(statement->ColumnCount(), static_cast<int>(FIELD_COUNT));
78 int i = 0; 78 int i = 0;
79 for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) { 79 for (i = BEGIN_FIELDS; i < INT64_FIELDS_END; ++i) {
80 kernel->put(static_cast<Int64Field>(i), statement->ColumnInt64(i)); 80 kernel->put(static_cast<Int64Field>(i), statement->ColumnInt64(i));
81 } 81 }
82 for ( ; i < TIME_FIELDS_END; ++i) { 82 for ( ; i < TIME_FIELDS_END; ++i) {
83 kernel->put(static_cast<TimeField>(i), 83 kernel->put(static_cast<TimeField>(i),
84 syncer::ProtoTimeToTime(statement->ColumnInt64(i))); 84 ProtoTimeToTime(statement->ColumnInt64(i)));
85 } 85 }
86 for ( ; i < ID_FIELDS_END; ++i) { 86 for ( ; i < ID_FIELDS_END; ++i) {
87 kernel->mutable_ref(static_cast<IdField>(i)).s_ = 87 kernel->mutable_ref(static_cast<IdField>(i)).s_ =
88 statement->ColumnString(i); 88 statement->ColumnString(i);
89 } 89 }
90 for ( ; i < BIT_FIELDS_END; ++i) { 90 for ( ; i < BIT_FIELDS_END; ++i) {
91 kernel->put(static_cast<BitField>(i), (0 != statement->ColumnInt(i))); 91 kernel->put(static_cast<BitField>(i), (0 != statement->ColumnInt(i)));
92 } 92 }
93 for ( ; i < STRING_FIELDS_END; ++i) { 93 for ( ; i < STRING_FIELDS_END; ++i) {
94 kernel->put(static_cast<StringField>(i), 94 kernel->put(static_cast<StringField>(i),
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 SafeDropTable("models"); 537 SafeDropTable("models");
538 SafeDropTable("temp_models"); 538 SafeDropTable("temp_models");
539 needs_column_refresh_ = false; 539 needs_column_refresh_ = false;
540 } 540 }
541 541
542 // static 542 // static
543 ModelType DirectoryBackingStore::ModelIdToModelTypeEnum( 543 ModelType DirectoryBackingStore::ModelIdToModelTypeEnum(
544 const void* data, int size) { 544 const void* data, int size) {
545 sync_pb::EntitySpecifics specifics; 545 sync_pb::EntitySpecifics specifics;
546 if (!specifics.ParseFromArray(data, size)) 546 if (!specifics.ParseFromArray(data, size))
547 return syncer::UNSPECIFIED; 547 return UNSPECIFIED;
548 return syncer::GetModelTypeFromSpecifics(specifics); 548 return GetModelTypeFromSpecifics(specifics);
549 } 549 }
550 550
551 // static 551 // static
552 string DirectoryBackingStore::ModelTypeEnumToModelId(ModelType model_type) { 552 string DirectoryBackingStore::ModelTypeEnumToModelId(ModelType model_type) {
553 sync_pb::EntitySpecifics specifics; 553 sync_pb::EntitySpecifics specifics;
554 syncer::AddDefaultFieldValue(model_type, &specifics); 554 AddDefaultFieldValue(model_type, &specifics);
555 return specifics.SerializeAsString(); 555 return specifics.SerializeAsString();
556 } 556 }
557 557
558 // static 558 // static
559 std::string DirectoryBackingStore::GenerateCacheGUID() { 559 std::string DirectoryBackingStore::GenerateCacheGUID() {
560 // Generate a GUID with 128 bits of randomness. 560 // Generate a GUID with 128 bits of randomness.
561 const int kGuidBytes = 128 / 8; 561 const int kGuidBytes = 128 / 8;
562 std::string guid; 562 std::string guid;
563 base::Base64Encode(base::RandBytesAsString(kGuidBytes), &guid); 563 base::Base64Encode(base::RandBytesAsString(kGuidBytes), &guid);
564 return guid; 564 return guid;
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 990
991 if (!CreateModelsTable()) 991 if (!CreateModelsTable())
992 return false; 992 return false;
993 993
994 // Create the big metas table. 994 // Create the big metas table.
995 if (!CreateMetasTable(false)) 995 if (!CreateMetasTable(false))
996 return false; 996 return false;
997 997
998 { 998 {
999 // Insert the entry for the root into the metas table. 999 // Insert the entry for the root into the metas table.
1000 const int64 now = syncer::TimeToProtoTime(base::Time::Now()); 1000 const int64 now = TimeToProtoTime(base::Time::Now());
1001 sql::Statement s(db_->GetUniqueStatement( 1001 sql::Statement s(db_->GetUniqueStatement(
1002 "INSERT INTO metas " 1002 "INSERT INTO metas "
1003 "( id, metahandle, is_dir, ctime, mtime) " 1003 "( id, metahandle, is_dir, ctime, mtime) "
1004 "VALUES ( \"r\", 1, 1, ?, ?)")); 1004 "VALUES ( \"r\", 1, 1, ?, ?)"));
1005 s.BindInt64(0, now); 1005 s.BindInt64(0, now);
1006 s.BindInt64(1, now); 1006 s.BindInt64(1, now);
1007 1007
1008 if (!s.Run()) 1008 if (!s.Run())
1009 return false; 1009 return false;
1010 } 1010 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 "store_birthday TEXT, " 1078 "store_birthday TEXT, "
1079 "db_create_version TEXT, " 1079 "db_create_version TEXT, "
1080 "db_create_time INT, " 1080 "db_create_time INT, "
1081 "next_id INT default -2, " 1081 "next_id INT default -2, "
1082 "cache_guid TEXT )"); 1082 "cache_guid TEXT )");
1083 return db_->Execute(query.c_str()); 1083 return db_->Execute(query.c_str());
1084 } 1084 }
1085 1085
1086 } // namespace syncable 1086 } // namespace syncable
1087 } // namespace syncer 1087 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/syncable/directory_backing_store.h ('k') | sync/syncable/directory_backing_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698