OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 GetAutofillMigrationState() { |
| 1113 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); |
| 1114 if (!lookup.good()) { |
| 1115 DCHECK(false) << "ScopedDirLookup failed when checking initial sync"; |
| 1116 return syncable::NOT_MIGRATED; |
| 1117 } |
| 1118 |
| 1119 return lookup->get_autofill_migration_state(); |
| 1120 } |
| 1121 |
| 1122 void SetAutofillMigrationState(syncable::AutofillMigrationState state) { |
| 1123 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); |
| 1124 if (!lookup.good()) { |
| 1125 DCHECK(false) << "ScopedDirLookup failed when checking initial sync"; |
| 1126 return; |
| 1127 } |
| 1128 |
| 1129 return lookup->set_autofill_migration_state(state); |
| 1130 } |
| 1131 |
| 1132 void SetAutofillMigrationDebugInfo( |
| 1133 syncable::AutofillMigrationDebugInfo::PropertyToSet property_to_set, |
| 1134 const syncable::AutofillMigrationDebugInfo& info) { |
| 1135 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); |
| 1136 if (!lookup.good()) { |
| 1137 DCHECK(false) << "ScopedDirLookup failed when checking initial sync"; |
| 1138 return; |
| 1139 } |
| 1140 |
| 1141 return lookup->set_autofill_migration_state_debug_info( |
| 1142 property_to_set, info); |
| 1143 } |
| 1144 |
| 1145 syncable::AutofillMigrationDebugInfo |
| 1146 GetAutofillMigrationDebugInfo() { |
| 1147 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); |
| 1148 if (!lookup.good()) { |
| 1149 DCHECK(false) << "ScopedDirLookup failed when checking initial sync"; |
| 1150 syncable::AutofillMigrationDebugInfo null_value = {0}; |
| 1151 return null_value; |
| 1152 } |
| 1153 return lookup->get_autofill_migration_debug_info(); |
| 1154 } |
| 1155 |
1097 // SyncEngineEventListener implementation. | 1156 // SyncEngineEventListener implementation. |
1098 virtual void OnSyncEngineEvent(const SyncEngineEvent& event); | 1157 virtual void OnSyncEngineEvent(const SyncEngineEvent& event); |
1099 private: | 1158 private: |
1100 // Helper to handle the details of initializing the TalkMediator. | 1159 // Helper to handle the details of initializing the TalkMediator. |
1101 // Must be called only after OpenDirectory() is called. | 1160 // Must be called only after OpenDirectory() is called. |
1102 void InitializeTalkMediator(); | 1161 void InitializeTalkMediator(); |
1103 | 1162 |
1104 // Helper to call OnAuthError when no authentication credentials are | 1163 // Helper to call OnAuthError when no authentication credentials are |
1105 // available. | 1164 // available. |
1106 void RaiseAuthNeededEvent(); | 1165 void RaiseAuthNeededEvent(); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 | 1367 |
1309 | 1368 |
1310 bool SyncManager::InitialSyncEndedForAllEnabledTypes() { | 1369 bool SyncManager::InitialSyncEndedForAllEnabledTypes() { |
1311 return data_->InitialSyncEndedForAllEnabledTypes(); | 1370 return data_->InitialSyncEndedForAllEnabledTypes(); |
1312 } | 1371 } |
1313 | 1372 |
1314 void SyncManager::StartSyncing() { | 1373 void SyncManager::StartSyncing() { |
1315 data_->StartSyncing(); | 1374 data_->StartSyncing(); |
1316 } | 1375 } |
1317 | 1376 |
| 1377 syncable::AutofillMigrationState |
| 1378 SyncManager::GetAutofillMigrationState() { |
| 1379 return data_->GetAutofillMigrationState(); |
| 1380 } |
| 1381 |
| 1382 void SyncManager::SetAutofillMigrationState( |
| 1383 syncable::AutofillMigrationState state) { |
| 1384 return data_->SetAutofillMigrationState(state); |
| 1385 } |
| 1386 |
| 1387 syncable::AutofillMigrationDebugInfo |
| 1388 SyncManager::GetAutofillMigrationDebugInfo() { |
| 1389 return data_->GetAutofillMigrationDebugInfo(); |
| 1390 } |
| 1391 |
| 1392 void SyncManager::SetAutofillMigrationDebugInfo( |
| 1393 syncable::AutofillMigrationDebugInfo::PropertyToSet property_to_set, |
| 1394 const syncable::AutofillMigrationDebugInfo& info) { |
| 1395 return data_->SetAutofillMigrationDebugInfo(property_to_set, info); |
| 1396 } |
| 1397 |
1318 void SyncManager::SetPassphrase(const std::string& passphrase, | 1398 void SyncManager::SetPassphrase(const std::string& passphrase, |
1319 bool is_explicit) { | 1399 bool is_explicit) { |
1320 data_->SetPassphrase(passphrase, is_explicit); | 1400 data_->SetPassphrase(passphrase, is_explicit); |
1321 } | 1401 } |
1322 | 1402 |
1323 bool SyncManager::IsUsingExplicitPassphrase() { | 1403 bool SyncManager::IsUsingExplicitPassphrase() { |
1324 return data_ && data_->IsUsingExplicitPassphrase(); | 1404 return data_ && data_->IsUsingExplicitPassphrase(); |
1325 } | 1405 } |
1326 | 1406 |
1327 bool SyncManager::RequestPause() { | 1407 bool SyncManager::RequestPause() { |
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2268 DCHECK(data_->initialized()) << "GetUserShare requires initialization!"; | 2348 DCHECK(data_->initialized()) << "GetUserShare requires initialization!"; |
2269 return data_->GetUserShare(); | 2349 return data_->GetUserShare(); |
2270 } | 2350 } |
2271 | 2351 |
2272 bool SyncManager::HasUnsyncedItems() const { | 2352 bool SyncManager::HasUnsyncedItems() const { |
2273 sync_api::ReadTransaction trans(GetUserShare()); | 2353 sync_api::ReadTransaction trans(GetUserShare()); |
2274 return (trans.GetWrappedTrans()->directory()->unsynced_entity_count() != 0); | 2354 return (trans.GetWrappedTrans()->directory()->unsynced_entity_count() != 0); |
2275 } | 2355 } |
2276 | 2356 |
2277 } // namespace sync_api | 2357 } // namespace sync_api |
OLD | NEW |