| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/internal_api/sync_manager.h" | 5 #include "chrome/browser/sync/internal_api/sync_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "base/observer_list_threadsafe.h" | |
| 16 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
| 17 #include "base/values.h" | 16 #include "base/values.h" |
| 18 #include "chrome/browser/sync/engine/all_status.h" | 17 #include "chrome/browser/sync/engine/all_status.h" |
| 19 #include "chrome/browser/sync/engine/net/server_connection_manager.h" | 18 #include "chrome/browser/sync/engine/net/server_connection_manager.h" |
| 20 #include "chrome/browser/sync/engine/nigori_util.h" | 19 #include "chrome/browser/sync/engine/nigori_util.h" |
| 21 #include "chrome/browser/sync/engine/syncapi_internal.h" | 20 #include "chrome/browser/sync/engine/syncapi_internal.h" |
| 22 #include "chrome/browser/sync/engine/syncer_types.h" | 21 #include "chrome/browser/sync/engine/syncer_types.h" |
| 23 #include "chrome/browser/sync/engine/sync_scheduler.h" | 22 #include "chrome/browser/sync/engine/sync_scheduler.h" |
| 24 #include "chrome/browser/sync/internal_api/base_node.h" | 23 #include "chrome/browser/sync/internal_api/base_node.h" |
| 25 #include "chrome/browser/sync/internal_api/change_reorder_buffer.h" | 24 #include "chrome/browser/sync/internal_api/change_reorder_buffer.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 public JsBackend, | 123 public JsBackend, |
| 125 public SyncEngineEventListener, | 124 public SyncEngineEventListener, |
| 126 public ServerConnectionEventListener, | 125 public ServerConnectionEventListener, |
| 127 public syncable::DirectoryChangeDelegate { | 126 public syncable::DirectoryChangeDelegate { |
| 128 static const int kDefaultNudgeDelayMilliseconds; | 127 static const int kDefaultNudgeDelayMilliseconds; |
| 129 static const int kPreferencesNudgeDelayMilliseconds; | 128 static const int kPreferencesNudgeDelayMilliseconds; |
| 130 public: | 129 public: |
| 131 explicit SyncInternal(const std::string& name) | 130 explicit SyncInternal(const std::string& name) |
| 132 : name_(name), | 131 : name_(name), |
| 133 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 132 weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
| 134 change_observers_( | |
| 135 new ObserverListThreadSafe<SyncManager::ChangeObserver>()), | |
| 136 registrar_(NULL), | 133 registrar_(NULL), |
| 137 change_delegate_(NULL), | 134 change_delegate_(NULL), |
| 138 initialized_(false), | 135 initialized_(false), |
| 139 setup_for_test_mode_(false), | 136 setup_for_test_mode_(false), |
| 140 observing_ip_address_changes_(false), | 137 observing_ip_address_changes_(false), |
| 141 created_on_loop_(MessageLoop::current()) { | 138 created_on_loop_(MessageLoop::current()) { |
| 142 // Pre-fill |notification_info_map_|. | 139 // Pre-fill |notification_info_map_|. |
| 143 for (int i = syncable::FIRST_REAL_MODEL_TYPE; | 140 for (int i = syncable::FIRST_REAL_MODEL_TYPE; |
| 144 i < syncable::MODEL_TYPE_COUNT; ++i) { | 141 i < syncable::MODEL_TYPE_COUNT; ++i) { |
| 145 notification_info_map_.insert( | 142 notification_info_map_.insert( |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 267 |
| 271 // SyncNotifierObserver implementation. | 268 // SyncNotifierObserver implementation. |
| 272 virtual void OnNotificationStateChange( | 269 virtual void OnNotificationStateChange( |
| 273 bool notifications_enabled) OVERRIDE; | 270 bool notifications_enabled) OVERRIDE; |
| 274 | 271 |
| 275 virtual void OnIncomingNotification( | 272 virtual void OnIncomingNotification( |
| 276 const syncable::ModelTypePayloadMap& type_payloads) OVERRIDE; | 273 const syncable::ModelTypePayloadMap& type_payloads) OVERRIDE; |
| 277 | 274 |
| 278 virtual void StoreState(const std::string& cookie) OVERRIDE; | 275 virtual void StoreState(const std::string& cookie) OVERRIDE; |
| 279 | 276 |
| 280 void AddChangeObserver(SyncManager::ChangeObserver* observer); | |
| 281 void RemoveChangeObserver(SyncManager::ChangeObserver* observer); | |
| 282 | |
| 283 void AddObserver(SyncManager::Observer* observer); | 277 void AddObserver(SyncManager::Observer* observer); |
| 284 void RemoveObserver(SyncManager::Observer* observer); | 278 void RemoveObserver(SyncManager::Observer* observer); |
| 285 | 279 |
| 286 // Accessors for the private members. | 280 // Accessors for the private members. |
| 287 DirectoryManager* dir_manager() { return share_.dir_manager.get(); } | 281 DirectoryManager* dir_manager() { return share_.dir_manager.get(); } |
| 288 SyncAPIServerConnectionManager* connection_manager() { | 282 SyncAPIServerConnectionManager* connection_manager() { |
| 289 return connection_manager_.get(); | 283 return connection_manager_.get(); |
| 290 } | 284 } |
| 291 SyncScheduler* scheduler() { return scheduler_.get(); } | 285 SyncScheduler* scheduler() { return scheduler_.get(); } |
| 292 UserShare* GetUserShare() { | 286 UserShare* GetUserShare() { |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 // we'd have another worker class which implements | 482 // we'd have another worker class which implements |
| 489 // HandleCalculateChangesChangeEventFromSyncApi() and we'd pass it a | 483 // HandleCalculateChangesChangeEventFromSyncApi() and we'd pass it a |
| 490 // WeakHandle when we construct it. | 484 // WeakHandle when we construct it. |
| 491 WeakHandle<SyncInternal> weak_handle_this_; | 485 WeakHandle<SyncInternal> weak_handle_this_; |
| 492 | 486 |
| 493 // We couple the DirectoryManager and username together in a UserShare member | 487 // We couple the DirectoryManager and username together in a UserShare member |
| 494 // so we can return a handle to share_ to clients of the API for use when | 488 // so we can return a handle to share_ to clients of the API for use when |
| 495 // constructing any transaction type. | 489 // constructing any transaction type. |
| 496 UserShare share_; | 490 UserShare share_; |
| 497 | 491 |
| 498 // Even though observers are always added/removed from the sync | 492 // This can be called from any thread, but only between calls to |
| 499 // thread, we still need to use a thread-safe observer list as we | 493 // OpenDirectory() and ShutdownOnSyncThread(). |
| 500 // can notify from any thread. | 494 browser_sync::WeakHandle<SyncManager::ChangeObserver> change_observer_; |
| 501 scoped_refptr<ObserverListThreadSafe<SyncManager::ChangeObserver> > | |
| 502 change_observers_; | |
| 503 | 495 |
| 504 ObserverList<SyncManager::Observer> observers_; | 496 ObserverList<SyncManager::Observer> observers_; |
| 505 | 497 |
| 506 // The ServerConnectionManager used to abstract communication between the | 498 // The ServerConnectionManager used to abstract communication between the |
| 507 // client (the Syncer) and the sync server. | 499 // client (the Syncer) and the sync server. |
| 508 scoped_ptr<SyncAPIServerConnectionManager> connection_manager_; | 500 scoped_ptr<SyncAPIServerConnectionManager> connection_manager_; |
| 509 | 501 |
| 510 // The scheduler that runs the Syncer. Needs to be explicitly | 502 // The scheduler that runs the Syncer. Needs to be explicitly |
| 511 // Start()ed. | 503 // Start()ed. |
| 512 scoped_ptr<SyncScheduler> scheduler_; | 504 scoped_ptr<SyncScheduler> scheduler_; |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 // Start the sync scheduler. This won't actually result in any | 878 // Start the sync scheduler. This won't actually result in any |
| 887 // syncing until at least the DirectoryManager broadcasts the OPENED | 879 // syncing until at least the DirectoryManager broadcasts the OPENED |
| 888 // event, and a valid server connection is detected. | 880 // event, and a valid server connection is detected. |
| 889 if (scheduler()) // NULL during certain unittests. | 881 if (scheduler()) // NULL during certain unittests. |
| 890 scheduler()->Start(SyncScheduler::NORMAL_MODE, base::Closure()); | 882 scheduler()->Start(SyncScheduler::NORMAL_MODE, base::Closure()); |
| 891 } | 883 } |
| 892 | 884 |
| 893 bool SyncManager::SyncInternal::OpenDirectory() { | 885 bool SyncManager::SyncInternal::OpenDirectory() { |
| 894 DCHECK(!initialized_) << "Should only happen once"; | 886 DCHECK(!initialized_) << "Should only happen once"; |
| 895 | 887 |
| 896 bool share_opened = dir_manager()->Open(username_for_share(), this); | 888 // Set before Open(). |
| 889 change_observer_ = |
| 890 browser_sync::MakeWeakHandle(js_mutation_event_observer_.AsWeakPtr()); |
| 891 |
| 892 bool share_opened = |
| 893 dir_manager()->Open( |
| 894 username_for_share(), |
| 895 this, |
| 896 browser_sync::MakeWeakHandle( |
| 897 js_mutation_event_observer_.AsWeakPtr())); |
| 897 DCHECK(share_opened); | 898 DCHECK(share_opened); |
| 898 if (!share_opened) { | 899 if (!share_opened) { |
| 899 LOG(ERROR) << "Could not open share for:" << username_for_share(); | 900 LOG(ERROR) << "Could not open share for:" << username_for_share(); |
| 900 return false; | 901 return false; |
| 901 } | 902 } |
| 902 | 903 |
| 903 // Database has to be initialized for the guid to be available. | 904 // Database has to be initialized for the guid to be available. |
| 904 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); | 905 syncable::ScopedDirLookup lookup(dir_manager(), username_for_share()); |
| 905 if (!lookup.good()) { | 906 if (!lookup.good()) { |
| 906 NOTREACHED(); | 907 NOTREACHED(); |
| 907 return false; | 908 return false; |
| 908 } | 909 } |
| 909 | 910 |
| 910 connection_manager()->set_client_id(lookup->cache_guid()); | 911 connection_manager()->set_client_id(lookup->cache_guid()); |
| 911 lookup->AddTransactionObserver(&js_mutation_event_observer_); | |
| 912 AddChangeObserver(&js_mutation_event_observer_); | |
| 913 return true; | 912 return true; |
| 914 } | 913 } |
| 915 | 914 |
| 916 bool SyncManager::SyncInternal::SignIn(const SyncCredentials& credentials) { | 915 bool SyncManager::SyncInternal::SignIn(const SyncCredentials& credentials) { |
| 917 DCHECK(thread_checker_.CalledOnValidThread()); | 916 DCHECK(thread_checker_.CalledOnValidThread()); |
| 918 DCHECK(share_.name.empty()); | 917 DCHECK(share_.name.empty()); |
| 919 share_.name = credentials.email; | 918 share_.name = credentials.email; |
| 920 | 919 |
| 921 VLOG(1) << "Signing in user: " << username_for_share(); | 920 VLOG(1) << "Signing in user: " << username_for_share(); |
| 922 if (!OpenDirectory()) | 921 if (!OpenDirectory()) |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 // NOTE: We notify from within a transaction. | 1215 // NOTE: We notify from within a transaction. |
| 1217 FOR_EACH_OBSERVER( | 1216 FOR_EACH_OBSERVER( |
| 1218 SyncManager::Observer, observers_, OnEncryptionComplete()); | 1217 SyncManager::Observer, observers_, OnEncryptionComplete()); |
| 1219 } | 1218 } |
| 1220 | 1219 |
| 1221 SyncManager::~SyncManager() { | 1220 SyncManager::~SyncManager() { |
| 1222 DCHECK(thread_checker_.CalledOnValidThread()); | 1221 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1223 delete data_; | 1222 delete data_; |
| 1224 } | 1223 } |
| 1225 | 1224 |
| 1226 void SyncManager::AddChangeObserver(ChangeObserver* observer) { | |
| 1227 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 1228 data_->AddChangeObserver(observer); | |
| 1229 } | |
| 1230 | |
| 1231 void SyncManager::RemoveChangeObserver(ChangeObserver* observer) { | |
| 1232 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 1233 data_->RemoveChangeObserver(observer); | |
| 1234 } | |
| 1235 | |
| 1236 void SyncManager::AddObserver(Observer* observer) { | 1225 void SyncManager::AddObserver(Observer* observer) { |
| 1237 DCHECK(thread_checker_.CalledOnValidThread()); | 1226 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1238 data_->AddObserver(observer); | 1227 data_->AddObserver(observer); |
| 1239 } | 1228 } |
| 1240 | 1229 |
| 1241 void SyncManager::RemoveObserver(Observer* observer) { | 1230 void SyncManager::RemoveObserver(Observer* observer) { |
| 1242 DCHECK(thread_checker_.CalledOnValidThread()); | 1231 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1243 data_->RemoveObserver(observer); | 1232 data_->RemoveObserver(observer); |
| 1244 } | 1233 } |
| 1245 | 1234 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1261 | 1250 |
| 1262 void SyncManager::ShutdownOnSyncThread() { | 1251 void SyncManager::ShutdownOnSyncThread() { |
| 1263 DCHECK(thread_checker_.CalledOnValidThread()); | 1252 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1264 data_->ShutdownOnSyncThread(); | 1253 data_->ShutdownOnSyncThread(); |
| 1265 } | 1254 } |
| 1266 | 1255 |
| 1267 void SyncManager::SyncInternal::ShutdownOnSyncThread() { | 1256 void SyncManager::SyncInternal::ShutdownOnSyncThread() { |
| 1268 DCHECK(thread_checker_.CalledOnValidThread()); | 1257 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1269 | 1258 |
| 1270 // Prevent any in-flight method calls from running. Also | 1259 // Prevent any in-flight method calls from running. Also |
| 1271 // invalidates |weak_handle_this_|. | 1260 // invalidates |weak_handle_this_| and |change_observer_|. |
| 1272 weak_ptr_factory_.InvalidateWeakPtrs(); | 1261 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 1262 js_mutation_event_observer_.InvalidateWeakPtrs(); |
| 1273 | 1263 |
| 1274 scheduler_.reset(); | 1264 scheduler_.reset(); |
| 1275 | 1265 |
| 1276 SetJsEventHandler(WeakHandle<JsEventHandler>()); | 1266 SetJsEventHandler(WeakHandle<JsEventHandler>()); |
| 1277 RemoveObserver(&js_sync_manager_observer_); | 1267 RemoveObserver(&js_sync_manager_observer_); |
| 1278 | 1268 |
| 1279 RemoveObserver(&debug_info_event_listener_); | 1269 RemoveObserver(&debug_info_event_listener_); |
| 1280 | 1270 |
| 1281 if (sync_notifier_.get()) { | 1271 if (sync_notifier_.get()) { |
| 1282 sync_notifier_->RemoveObserver(this); | 1272 sync_notifier_->RemoveObserver(this); |
| 1283 } | 1273 } |
| 1284 sync_notifier_.reset(); | 1274 sync_notifier_.reset(); |
| 1285 | 1275 |
| 1286 if (connection_manager_.get()) { | 1276 if (connection_manager_.get()) { |
| 1287 connection_manager_->RemoveListener(this); | 1277 connection_manager_->RemoveListener(this); |
| 1288 } | 1278 } |
| 1289 connection_manager_.reset(); | 1279 connection_manager_.reset(); |
| 1290 | 1280 |
| 1291 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); | 1281 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); |
| 1292 observing_ip_address_changes_ = false; | 1282 observing_ip_address_changes_ = false; |
| 1293 | 1283 |
| 1294 if (dir_manager()) { | 1284 if (dir_manager()) { |
| 1295 { | 1285 { |
| 1296 // Cryptographer should only be accessed while holding a | 1286 // Cryptographer should only be accessed while holding a |
| 1297 // transaction. | 1287 // transaction. |
| 1298 ReadTransaction trans(FROM_HERE, GetUserShare()); | 1288 ReadTransaction trans(FROM_HERE, GetUserShare()); |
| 1299 trans.GetCryptographer()->RemoveObserver(this); | 1289 trans.GetCryptographer()->RemoveObserver(this); |
| 1300 trans.GetLookup()-> | |
| 1301 RemoveTransactionObserver(&js_mutation_event_observer_); | |
| 1302 RemoveChangeObserver(&js_mutation_event_observer_); | |
| 1303 } | 1290 } |
| 1304 dir_manager()->FinalSaveChangesForAll(); | 1291 dir_manager()->FinalSaveChangesForAll(); |
| 1305 dir_manager()->Close(username_for_share()); | 1292 dir_manager()->Close(username_for_share()); |
| 1306 } | 1293 } |
| 1307 | 1294 |
| 1308 // Reset the DirectoryManager and UserSettings so they relinquish sqlite | 1295 // Reset the DirectoryManager and UserSettings so they relinquish sqlite |
| 1309 // handles to backing files. | 1296 // handles to backing files. |
| 1310 share_.dir_manager.reset(); | 1297 share_.dir_manager.reset(); |
| 1311 | 1298 |
| 1312 setup_for_test_mode_ = false; | 1299 setup_for_test_mode_ = false; |
| 1313 change_delegate_ = NULL; | 1300 change_delegate_ = NULL; |
| 1314 registrar_ = NULL; | 1301 registrar_ = NULL; |
| 1315 | 1302 |
| 1316 initialized_ = false; | 1303 initialized_ = false; |
| 1317 | 1304 |
| 1318 // We reset this here, since only now we know it will not be | 1305 // We reset these here, since only now we know they will not be |
| 1319 // accessed from other threads (since we shut down everything). | 1306 // accessed from other threads (since we shut down everything). |
| 1307 change_observer_.Reset(); |
| 1320 weak_handle_this_.Reset(); | 1308 weak_handle_this_.Reset(); |
| 1321 } | 1309 } |
| 1322 | 1310 |
| 1323 void SyncManager::SyncInternal::OnIPAddressChanged() { | 1311 void SyncManager::SyncInternal::OnIPAddressChanged() { |
| 1324 VLOG(1) << "IP address change detected"; | 1312 VLOG(1) << "IP address change detected"; |
| 1325 if (!observing_ip_address_changes_) { | 1313 if (!observing_ip_address_changes_) { |
| 1326 VLOG(1) << "IP address change dropped."; | 1314 VLOG(1) << "IP address change dropped."; |
| 1327 return; | 1315 return; |
| 1328 } | 1316 } |
| 1329 | 1317 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1375 // released. This allows work to be performed without blocking other threads | 1363 // released. This allows work to be performed without blocking other threads |
| 1376 // from acquiring a transaction. | 1364 // from acquiring a transaction. |
| 1377 if (!change_delegate_) | 1365 if (!change_delegate_) |
| 1378 return; | 1366 return; |
| 1379 | 1367 |
| 1380 // Call commit. | 1368 // Call commit. |
| 1381 for (int i = 0; i < syncable::MODEL_TYPE_COUNT; ++i) { | 1369 for (int i = 0; i < syncable::MODEL_TYPE_COUNT; ++i) { |
| 1382 const syncable::ModelType type = syncable::ModelTypeFromInt(i); | 1370 const syncable::ModelType type = syncable::ModelTypeFromInt(i); |
| 1383 if (models_with_changes.test(type)) { | 1371 if (models_with_changes.test(type)) { |
| 1384 change_delegate_->OnChangesComplete(type); | 1372 change_delegate_->OnChangesComplete(type); |
| 1385 change_observers_->Notify( | 1373 change_observer_.Call(FROM_HERE, |
| 1386 &SyncManager::ChangeObserver::OnChangesComplete, type); | 1374 &SyncManager::ChangeObserver::OnChangesComplete, type); |
| 1387 } | 1375 } |
| 1388 } | 1376 } |
| 1389 } | 1377 } |
| 1390 | 1378 |
| 1391 ModelTypeBitSet SyncManager::SyncInternal::HandleTransactionEndingChangeEvent( | 1379 ModelTypeBitSet SyncManager::SyncInternal::HandleTransactionEndingChangeEvent( |
| 1392 const ImmutableWriteTransactionInfo& write_transaction_info, | 1380 const ImmutableWriteTransactionInfo& write_transaction_info, |
| 1393 syncable::BaseTransaction* trans) { | 1381 syncable::BaseTransaction* trans) { |
| 1394 // This notification happens immediately before a syncable WriteTransaction | 1382 // This notification happens immediately before a syncable WriteTransaction |
| 1395 // falls out of scope. It happens while the channel mutex is still held, | 1383 // falls out of scope. It happens while the channel mutex is still held, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1411 continue; | 1399 continue; |
| 1412 | 1400 |
| 1413 ImmutableChangeRecordList ordered_changes; | 1401 ImmutableChangeRecordList ordered_changes; |
| 1414 // TODO(akalin): Propagate up the error further (see | 1402 // TODO(akalin): Propagate up the error further (see |
| 1415 // http://crbug.com/100907). | 1403 // http://crbug.com/100907). |
| 1416 CHECK(change_buffers_[type].GetAllChangesInTreeOrder(&read_trans, | 1404 CHECK(change_buffers_[type].GetAllChangesInTreeOrder(&read_trans, |
| 1417 &ordered_changes)); | 1405 &ordered_changes)); |
| 1418 if (!ordered_changes.Get().empty()) { | 1406 if (!ordered_changes.Get().empty()) { |
| 1419 change_delegate_-> | 1407 change_delegate_-> |
| 1420 OnChangesApplied(type, &read_trans, ordered_changes); | 1408 OnChangesApplied(type, &read_trans, ordered_changes); |
| 1421 change_observers_->Notify( | 1409 change_observer_.Call(FROM_HERE, |
| 1422 &SyncManager::ChangeObserver::OnChangesApplied, | 1410 &SyncManager::ChangeObserver::OnChangesApplied, |
| 1423 type, write_transaction_info.Get().id, ordered_changes); | 1411 type, write_transaction_info.Get().id, ordered_changes); |
| 1424 models_with_changes.set(i, true); | 1412 models_with_changes.set(i, true); |
| 1425 } | 1413 } |
| 1426 change_buffers_[i].Clear(); | 1414 change_buffers_[i].Clear(); |
| 1427 } | 1415 } |
| 1428 return models_with_changes; | 1416 return models_with_changes; |
| 1429 } | 1417 } |
| 1430 | 1418 |
| 1431 void SyncManager::SyncInternal::HandleCalculateChangesChangeEventFromSyncApi( | 1419 void SyncManager::SyncInternal::HandleCalculateChangesChangeEventFromSyncApi( |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1955 } | 1943 } |
| 1956 if (VLOG_IS_ON(1)) { | 1944 if (VLOG_IS_ON(1)) { |
| 1957 std::string encoded_state; | 1945 std::string encoded_state; |
| 1958 base::Base64Encode(state, &encoded_state); | 1946 base::Base64Encode(state, &encoded_state); |
| 1959 VLOG(1) << "Writing notification state: " << encoded_state; | 1947 VLOG(1) << "Writing notification state: " << encoded_state; |
| 1960 } | 1948 } |
| 1961 lookup->SetNotificationState(state); | 1949 lookup->SetNotificationState(state); |
| 1962 lookup->SaveChanges(); | 1950 lookup->SaveChanges(); |
| 1963 } | 1951 } |
| 1964 | 1952 |
| 1965 void SyncManager::SyncInternal::AddChangeObserver( | |
| 1966 SyncManager::ChangeObserver* observer) { | |
| 1967 change_observers_->AddObserver(observer); | |
| 1968 } | |
| 1969 | |
| 1970 void SyncManager::SyncInternal::RemoveChangeObserver( | |
| 1971 SyncManager::ChangeObserver* observer) { | |
| 1972 change_observers_->RemoveObserver(observer); | |
| 1973 } | |
| 1974 | |
| 1975 void SyncManager::SyncInternal::AddObserver( | 1953 void SyncManager::SyncInternal::AddObserver( |
| 1976 SyncManager::Observer* observer) { | 1954 SyncManager::Observer* observer) { |
| 1977 observers_.AddObserver(observer); | 1955 observers_.AddObserver(observer); |
| 1978 } | 1956 } |
| 1979 | 1957 |
| 1980 void SyncManager::SyncInternal::RemoveObserver( | 1958 void SyncManager::SyncInternal::RemoveObserver( |
| 1981 SyncManager::Observer* observer) { | 1959 SyncManager::Observer* observer) { |
| 1982 observers_.RemoveObserver(observer); | 1960 observers_.RemoveObserver(observer); |
| 1983 } | 1961 } |
| 1984 | 1962 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2109 lookup->GetDownloadProgress(*i, &marker); | 2087 lookup->GetDownloadProgress(*i, &marker); |
| 2110 | 2088 |
| 2111 if (marker.token().empty()) | 2089 if (marker.token().empty()) |
| 2112 result.insert(*i); | 2090 result.insert(*i); |
| 2113 | 2091 |
| 2114 } | 2092 } |
| 2115 return result; | 2093 return result; |
| 2116 } | 2094 } |
| 2117 | 2095 |
| 2118 } // namespace sync_api | 2096 } // namespace sync_api |
| OLD | NEW |