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

Side by Side Diff: chrome/browser/sync/engine/syncapi.cc

Issue 5159001: Rest of the autofill work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Couple of lint errors sneaked into my previous patch. This is clean of lint errors. Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/engine/syncapi.h" 5 #include "chrome/browser/sync/engine/syncapi.h"
6 6
7 #include <bitset> 7 #include <bitset>
8 #include <iomanip> 8 #include <iomanip>
9 #include <list> 9 #include <list>
10 #include <string> 10 #include <string>
(...skipping 25 matching lines...) Expand all
36 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h" 36 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
37 #include "chrome/browser/sync/protocol/extension_specifics.pb.h" 37 #include "chrome/browser/sync/protocol/extension_specifics.pb.h"
38 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h" 38 #include "chrome/browser/sync/protocol/nigori_specifics.pb.h"
39 #include "chrome/browser/sync/protocol/preference_specifics.pb.h" 39 #include "chrome/browser/sync/protocol/preference_specifics.pb.h"
40 #include "chrome/browser/sync/protocol/session_specifics.pb.h" 40 #include "chrome/browser/sync/protocol/session_specifics.pb.h"
41 #include "chrome/browser/sync/protocol/service_constants.h" 41 #include "chrome/browser/sync/protocol/service_constants.h"
42 #include "chrome/browser/sync/protocol/sync.pb.h" 42 #include "chrome/browser/sync/protocol/sync.pb.h"
43 #include "chrome/browser/sync/protocol/theme_specifics.pb.h" 43 #include "chrome/browser/sync/protocol/theme_specifics.pb.h"
44 #include "chrome/browser/sync/protocol/typed_url_specifics.pb.h" 44 #include "chrome/browser/sync/protocol/typed_url_specifics.pb.h"
45 #include "chrome/browser/sync/sessions/sync_session_context.h" 45 #include "chrome/browser/sync/sessions/sync_session_context.h"
46 #include "chrome/browser/sync/syncable/autofill_migration.h"
46 #include "chrome/browser/sync/syncable/directory_manager.h" 47 #include "chrome/browser/sync/syncable/directory_manager.h"
47 #include "chrome/browser/sync/syncable/syncable.h" 48 #include "chrome/browser/sync/syncable/syncable.h"
48 #include "chrome/browser/sync/util/crypto_helpers.h" 49 #include "chrome/browser/sync/util/crypto_helpers.h"
49 #include "chrome/common/chrome_switches.h" 50 #include "chrome/common/chrome_switches.h"
50 #include "chrome/common/deprecated/event_sys.h" 51 #include "chrome/common/deprecated/event_sys.h"
51 #include "chrome/common/net/gaia/gaia_authenticator.h" 52 #include "chrome/common/net/gaia/gaia_authenticator.h"
52 #include "jingle/notifier/listener/mediator_thread_impl.h" 53 #include "jingle/notifier/listener/mediator_thread_impl.h"
53 #include "jingle/notifier/listener/notification_constants.h" 54 #include "jingle/notifier/listener/notification_constants.h"
54 #include "jingle/notifier/listener/talk_mediator.h" 55 #include "jingle/notifier/listener/talk_mediator.h"
55 #include "jingle/notifier/listener/talk_mediator_impl.h" 56 #include "jingle/notifier/listener/talk_mediator_impl.h"
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 PutAutofillSpecificsAndMarkForSyncing(new_value); 369 PutAutofillSpecificsAndMarkForSyncing(new_value);
369 } 370 }
370 371
371 void WriteNode::PutAutofillSpecificsAndMarkForSyncing( 372 void WriteNode::PutAutofillSpecificsAndMarkForSyncing(
372 const sync_pb::AutofillSpecifics& new_value) { 373 const sync_pb::AutofillSpecifics& new_value) {
373 sync_pb::EntitySpecifics entity_specifics; 374 sync_pb::EntitySpecifics entity_specifics;
374 entity_specifics.MutableExtension(sync_pb::autofill)->CopyFrom(new_value); 375 entity_specifics.MutableExtension(sync_pb::autofill)->CopyFrom(new_value);
375 PutSpecificsAndMarkForSyncing(entity_specifics); 376 PutSpecificsAndMarkForSyncing(entity_specifics);
376 } 377 }
377 378
379 void WriteNode::SetAutofillProfileSpecifics(
380 const sync_pb::AutofillProfileSpecifics& new_value) {
381 DCHECK_EQ(GetModelType(), syncable::AUTOFILL_PROFILE);
382 PutAutofillProfileSpecificsAndMarkForSyncing(new_value);
383 }
384
385 void WriteNode::PutAutofillProfileSpecificsAndMarkForSyncing(
386 const sync_pb::AutofillProfileSpecifics& new_value) {
387 sync_pb::EntitySpecifics entity_specifics;
388 entity_specifics.MutableExtension(sync_pb::autofill_profile)->CopyFrom(
389 new_value);
390 PutSpecificsAndMarkForSyncing(entity_specifics);
391 }
392
378 void WriteNode::SetBookmarkSpecifics( 393 void WriteNode::SetBookmarkSpecifics(
379 const sync_pb::BookmarkSpecifics& new_value) { 394 const sync_pb::BookmarkSpecifics& new_value) {
380 DCHECK(GetModelType() == syncable::BOOKMARKS); 395 DCHECK(GetModelType() == syncable::BOOKMARKS);
381 PutBookmarkSpecificsAndMarkForSyncing(new_value); 396 PutBookmarkSpecificsAndMarkForSyncing(new_value);
382 } 397 }
383 398
384 void WriteNode::PutBookmarkSpecificsAndMarkForSyncing( 399 void WriteNode::PutBookmarkSpecificsAndMarkForSyncing(
385 const sync_pb::BookmarkSpecifics& new_value) { 400 const sync_pb::BookmarkSpecifics& new_value) {
386 sync_pb::EntitySpecifics entity_specifics; 401 sync_pb::EntitySpecifics entity_specifics;
387 entity_specifics.MutableExtension(sync_pb::bookmark)->CopyFrom(new_value); 402 entity_specifics.MutableExtension(sync_pb::bookmark)->CopyFrom(new_value);
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 ModelSafeRoutingInfo enabled_types; 1102 ModelSafeRoutingInfo enabled_types;
1088 registrar_->GetModelSafeRoutingInfo(&enabled_types); 1103 registrar_->GetModelSafeRoutingInfo(&enabled_types);
1089 for (ModelSafeRoutingInfo::const_iterator i = enabled_types.begin(); 1104 for (ModelSafeRoutingInfo::const_iterator i = enabled_types.begin();
1090 i != enabled_types.end(); ++i) { 1105 i != enabled_types.end(); ++i) {
1091 if (!lookup->initial_sync_ended_for_type(i->first)) 1106 if (!lookup->initial_sync_ended_for_type(i->first))
1092 return false; 1107 return false;
1093 } 1108 }
1094 return true; 1109 return true;
1095 } 1110 }
1096 1111
1112 syncable::AutofillMigrationState
1113 GetAutofillMigrationState() {
tim (not reviewing) 2010/12/13 19:24:33 indent or previous line
lipalani 2010/12/14 21:05:57 Done.
1114 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share());
1115 if (!lookup.good()) {
1116 DCHECK(false) << "ScopedDirLookup failed when checking initial sync";
1117 return
1118 syncable::NOT_MIGRATED;
tim (not reviewing) 2010/12/13 19:24:33 previous line?
lipalani 2010/12/14 21:05:57 Done.
1119 }
1120
1121 return lookup->get_autofill_migration_state();
1122 }
1123
1124 void SetAutofillMigrationState(
1125 syncable::AutofillMigrationState state) {
tim (not reviewing) 2010/12/13 19:24:33 previous line? or indent 4
lipalani 2010/12/14 21:05:57 Done.
1126 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share());
1127 if (!lookup.good()) {
1128 DCHECK(false) << "ScopedDirLookup failed when checking initial sync";
1129 return;
1130 }
1131
1132 return lookup->set_autofill_migration_state(state);
1133 }
1134
1135 void SetAutofillMigrationDebugInfo(
1136 syncable::AutofillMigrationDebugInfo::PropertyToSet property_to_set,
1137 const syncable::AutofillMigrationDebugInfo& info) {
1138 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share());
1139 if (!lookup.good()) {
1140 DCHECK(false) << "ScopedDirLookup failed when checking initial sync";
1141 return;
1142 }
1143
1144 return
1145 lookup->set_autofill_migration_state_debug_info(property_to_set, info);
tim (not reviewing) 2010/12/13 19:24:33 should start this on the previous line and then in
lipalani 2010/12/14 21:05:57 Done.
1146 }
1147
1148 syncable::AutofillMigrationDebugInfo
1149 GetAutofillMigrationDebugInfo() {
1150 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share());
1151 if (!lookup.good()) {
1152 DCHECK(false) << "ScopedDirLookup failed when checking initial sync";
1153 syncable::AutofillMigrationDebugInfo null_value = {0};
1154 return null_value;
1155 }
1156 return lookup->get_autofill_migration_debug_info();
1157 }
1158
1097 // SyncEngineEventListener implementation. 1159 // SyncEngineEventListener implementation.
1098 virtual void OnSyncEngineEvent(const SyncEngineEvent& event); 1160 virtual void OnSyncEngineEvent(const SyncEngineEvent& event);
1099 private: 1161 private:
1100 // Helper to handle the details of initializing the TalkMediator. 1162 // Helper to handle the details of initializing the TalkMediator.
1101 // Must be called only after OpenDirectory() is called. 1163 // Must be called only after OpenDirectory() is called.
1102 void InitializeTalkMediator(); 1164 void InitializeTalkMediator();
1103 1165
1104 // Helper to call OnAuthError when no authentication credentials are 1166 // Helper to call OnAuthError when no authentication credentials are
1105 // available. 1167 // available.
1106 void RaiseAuthNeededEvent(); 1168 void RaiseAuthNeededEvent();
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 1370
1309 1371
1310 bool SyncManager::InitialSyncEndedForAllEnabledTypes() { 1372 bool SyncManager::InitialSyncEndedForAllEnabledTypes() {
1311 return data_->InitialSyncEndedForAllEnabledTypes(); 1373 return data_->InitialSyncEndedForAllEnabledTypes();
1312 } 1374 }
1313 1375
1314 void SyncManager::StartSyncing() { 1376 void SyncManager::StartSyncing() {
1315 data_->StartSyncing(); 1377 data_->StartSyncing();
1316 } 1378 }
1317 1379
1380 syncable::AutofillMigrationState
1381 SyncManager::GetAutofillMigrationState() {
1382 return data_->GetAutofillMigrationState();
1383 }
1384
1385 void SyncManager::SetAutofillMigrationState(
1386 syncable::AutofillMigrationState state) {
1387 return data_->SetAutofillMigrationState(state);
1388 }
1389
1390 syncable::AutofillMigrationDebugInfo
1391 SyncManager::GetAutofillMigrationDebugInfo() {
1392 return data_->GetAutofillMigrationDebugInfo();
1393 }
1394
1395 void SyncManager::SetAutofillMigrationDebugInfo(
1396 syncable::AutofillMigrationDebugInfo::PropertyToSet property_to_set,
1397 const syncable::AutofillMigrationDebugInfo& info) {
1398 return data_->SetAutofillMigrationDebugInfo(property_to_set, info);
1399 }
1400
1318 void SyncManager::SetPassphrase(const std::string& passphrase, 1401 void SyncManager::SetPassphrase(const std::string& passphrase,
1319 bool is_explicit) { 1402 bool is_explicit) {
1320 data_->SetPassphrase(passphrase, is_explicit); 1403 data_->SetPassphrase(passphrase, is_explicit);
1321 } 1404 }
1322 1405
1323 bool SyncManager::IsUsingExplicitPassphrase() { 1406 bool SyncManager::IsUsingExplicitPassphrase() {
1324 return data_ && data_->IsUsingExplicitPassphrase(); 1407 return data_ && data_->IsUsingExplicitPassphrase();
1325 } 1408 }
1326 1409
1327 bool SyncManager::RequestPause() { 1410 bool SyncManager::RequestPause() {
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
2268 DCHECK(data_->initialized()) << "GetUserShare requires initialization!"; 2351 DCHECK(data_->initialized()) << "GetUserShare requires initialization!";
2269 return data_->GetUserShare(); 2352 return data_->GetUserShare();
2270 } 2353 }
2271 2354
2272 bool SyncManager::HasUnsyncedItems() const { 2355 bool SyncManager::HasUnsyncedItems() const {
2273 sync_api::ReadTransaction trans(GetUserShare()); 2356 sync_api::ReadTransaction trans(GetUserShare());
2274 return (trans.GetWrappedTrans()->directory()->unsynced_entity_count() != 0); 2357 return (trans.GetWrappedTrans()->directory()->unsynced_entity_count() != 0);
2275 } 2358 }
2276 2359
2277 } // namespace sync_api 2360 } // namespace sync_api
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698