Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/internal_api/sync_manager_impl.h" | 5 #include "sync/internal_api/sync_manager_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 connection_manager_->set_client_id(directory()->cache_guid()); | 387 connection_manager_->set_client_id(directory()->cache_guid()); |
| 388 connection_manager_->AddListener(this); | 388 connection_manager_->AddListener(this); |
| 389 | 389 |
| 390 std::string sync_id = directory()->cache_guid(); | 390 std::string sync_id = directory()->cache_guid(); |
| 391 | 391 |
| 392 DVLOG(1) << "Setting sync client ID: " << sync_id; | 392 DVLOG(1) << "Setting sync client ID: " << sync_id; |
| 393 allstatus_.SetSyncId(sync_id); | 393 allstatus_.SetSyncId(sync_id); |
| 394 DVLOG(1) << "Setting invalidator client ID: " << invalidator_client_id; | 394 DVLOG(1) << "Setting invalidator client ID: " << invalidator_client_id; |
| 395 allstatus_.SetInvalidatorClientId(invalidator_client_id); | 395 allstatus_.SetInvalidatorClientId(invalidator_client_id); |
| 396 | 396 |
| 397 model_type_registry_.reset(new ModelTypeRegistry(workers, directory())); | 397 model_type_registry_.reset(new ModelTypeRegistry(workers, directory(), this)); |
| 398 | 398 |
| 399 // Bind the SyncContext WeakPtr to this thread. This helps us crash earlier | 399 // Bind the SyncContext WeakPtr to this thread. This helps us crash earlier |
| 400 // if the pointer is misused in debug mode. | 400 // if the pointer is misused in debug mode. |
| 401 base::WeakPtr<SyncContext> weak_core = model_type_registry_->AsWeakPtr(); | 401 base::WeakPtr<SyncContext> weak_core = model_type_registry_->AsWeakPtr(); |
| 402 weak_core.get(); | 402 weak_core.get(); |
| 403 | 403 |
| 404 sync_context_proxy_.reset( | 404 sync_context_proxy_.reset( |
| 405 new SyncContextProxyImpl(base::MessageLoopProxy::current(), weak_core)); | 405 new SyncContextProxyImpl(base::MessageLoopProxy::current(), weak_core)); |
| 406 | 406 |
| 407 // Build a SyncSessionContext and store the worker in it. | 407 // Build a SyncSessionContext and store the worker in it. |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 891 | 891 |
| 892 // TODO(lipalani) : Calculate the nudge delay based on all types. | 892 // TODO(lipalani) : Calculate the nudge delay based on all types. |
| 893 base::TimeDelta nudge_delay = NudgeStrategy::GetNudgeDelayTimeDelta( | 893 base::TimeDelta nudge_delay = NudgeStrategy::GetNudgeDelayTimeDelta( |
| 894 types.First().Get(), | 894 types.First().Get(), |
| 895 this); | 895 this); |
| 896 scheduler_->ScheduleLocalNudge(nudge_delay, | 896 scheduler_->ScheduleLocalNudge(nudge_delay, |
| 897 types, | 897 types, |
| 898 nudge_location); | 898 nudge_location); |
| 899 } | 899 } |
| 900 | 900 |
| 901 void SyncManagerImpl::NudgeForInitialDownload(syncer::ModelType type) { | |
| 902 // TODO(rlarocque): Initial downloads should have a separate nudge type. | |
| 903 RefreshTypes(ModelTypeSet(type)); | |
| 904 } | |
| 905 | |
| 906 void SyncManagerImpl::NudgeForCommit(syncer::ModelType type) { | |
| 907 RequestNudgeForDataTypes(FROM_HERE, ModelTypeSet(type)); | |
|
pavely
2014/07/09 23:13:18
Could you check thread either here or in RequestNu
rlarocque
2014/07/10 00:12:29
Done.
| |
| 908 } | |
| 909 | |
| 910 void SyncManagerImpl::NudgeForRefresh(syncer::ModelType type) { | |
| 911 RefreshTypes(ModelTypeSet(type)); | |
| 912 } | |
| 913 | |
| 901 void SyncManagerImpl::OnSyncCycleEvent(const SyncCycleEvent& event) { | 914 void SyncManagerImpl::OnSyncCycleEvent(const SyncCycleEvent& event) { |
| 902 DCHECK(thread_checker_.CalledOnValidThread()); | 915 DCHECK(thread_checker_.CalledOnValidThread()); |
| 903 // Only send an event if this is due to a cycle ending and this cycle | 916 // Only send an event if this is due to a cycle ending and this cycle |
| 904 // concludes a canonical "sync" process; that is, based on what is known | 917 // concludes a canonical "sync" process; that is, based on what is known |
| 905 // locally we are "all happy" and up-to-date. There may be new changes on | 918 // locally we are "all happy" and up-to-date. There may be new changes on |
| 906 // the server, but we'll get them on a subsequent sync. | 919 // the server, but we'll get them on a subsequent sync. |
| 907 // | 920 // |
| 908 // Notifications are sent at the end of every sync cycle, regardless of | 921 // Notifications are sent at the end of every sync cycle, regardless of |
| 909 // whether we should sync again. | 922 // whether we should sync again. |
| 910 if (event.what_happened == SyncCycleEvent::SYNC_CYCLE_ENDED) { | 923 if (event.what_happened == SyncCycleEvent::SYNC_CYCLE_ENDED) { |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1147 int SyncManagerImpl::GetDefaultNudgeDelay() { | 1160 int SyncManagerImpl::GetDefaultNudgeDelay() { |
| 1148 return kDefaultNudgeDelayMilliseconds; | 1161 return kDefaultNudgeDelayMilliseconds; |
| 1149 } | 1162 } |
| 1150 | 1163 |
| 1151 // static. | 1164 // static. |
| 1152 int SyncManagerImpl::GetPreferencesNudgeDelay() { | 1165 int SyncManagerImpl::GetPreferencesNudgeDelay() { |
| 1153 return kPreferencesNudgeDelayMilliseconds; | 1166 return kPreferencesNudgeDelayMilliseconds; |
| 1154 } | 1167 } |
| 1155 | 1168 |
| 1156 } // namespace syncer | 1169 } // namespace syncer |
| OLD | NEW |