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

Side by Side Diff: sync/internal_api/sync_manager_impl.cc

Issue 375023002: sync: Support nudges from non-blocking sync types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 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
« no previous file with comments | « sync/internal_api/sync_manager_impl.h ('k') | sync/sessions/model_type_registry.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 connection_manager_->set_client_id(directory()->cache_guid()); 389 connection_manager_->set_client_id(directory()->cache_guid());
390 connection_manager_->AddListener(this); 390 connection_manager_->AddListener(this);
391 391
392 std::string sync_id = directory()->cache_guid(); 392 std::string sync_id = directory()->cache_guid();
393 393
394 DVLOG(1) << "Setting sync client ID: " << sync_id; 394 DVLOG(1) << "Setting sync client ID: " << sync_id;
395 allstatus_.SetSyncId(sync_id); 395 allstatus_.SetSyncId(sync_id);
396 DVLOG(1) << "Setting invalidator client ID: " << invalidator_client_id; 396 DVLOG(1) << "Setting invalidator client ID: " << invalidator_client_id;
397 allstatus_.SetInvalidatorClientId(invalidator_client_id); 397 allstatus_.SetInvalidatorClientId(invalidator_client_id);
398 398
399 model_type_registry_.reset(new ModelTypeRegistry(workers, directory())); 399 model_type_registry_.reset(new ModelTypeRegistry(workers, directory(), this));
400 400
401 // Bind the SyncContext WeakPtr to this thread. This helps us crash earlier 401 // Bind the SyncContext WeakPtr to this thread. This helps us crash earlier
402 // if the pointer is misused in debug mode. 402 // if the pointer is misused in debug mode.
403 base::WeakPtr<SyncContext> weak_core = model_type_registry_->AsWeakPtr(); 403 base::WeakPtr<SyncContext> weak_core = model_type_registry_->AsWeakPtr();
404 weak_core.get(); 404 weak_core.get();
405 405
406 sync_context_proxy_.reset( 406 sync_context_proxy_.reset(
407 new SyncContextProxyImpl(base::ThreadTaskRunnerHandle::Get(), weak_core)); 407 new SyncContextProxyImpl(base::ThreadTaskRunnerHandle::Get(), weak_core));
408 408
409 // Build a SyncSessionContext and store the worker in it. 409 // Build a SyncSessionContext and store the worker in it.
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 893
894 // TODO(lipalani) : Calculate the nudge delay based on all types. 894 // TODO(lipalani) : Calculate the nudge delay based on all types.
895 base::TimeDelta nudge_delay = NudgeStrategy::GetNudgeDelayTimeDelta( 895 base::TimeDelta nudge_delay = NudgeStrategy::GetNudgeDelayTimeDelta(
896 types.First().Get(), 896 types.First().Get(),
897 this); 897 this);
898 scheduler_->ScheduleLocalNudge(nudge_delay, 898 scheduler_->ScheduleLocalNudge(nudge_delay,
899 types, 899 types,
900 nudge_location); 900 nudge_location);
901 } 901 }
902 902
903 void SyncManagerImpl::NudgeForInitialDownload(syncer::ModelType type) {
904 // TODO(rlarocque): Initial downloads should have a separate nudge type.
905 DCHECK(thread_checker_.CalledOnValidThread());
906 RefreshTypes(ModelTypeSet(type));
907 }
908
909 void SyncManagerImpl::NudgeForCommit(syncer::ModelType type) {
910 DCHECK(thread_checker_.CalledOnValidThread());
911 RequestNudgeForDataTypes(FROM_HERE, ModelTypeSet(type));
912 }
913
914 void SyncManagerImpl::NudgeForRefresh(syncer::ModelType type) {
915 DCHECK(thread_checker_.CalledOnValidThread());
916 RefreshTypes(ModelTypeSet(type));
917 }
918
903 void SyncManagerImpl::OnSyncCycleEvent(const SyncCycleEvent& event) { 919 void SyncManagerImpl::OnSyncCycleEvent(const SyncCycleEvent& event) {
904 DCHECK(thread_checker_.CalledOnValidThread()); 920 DCHECK(thread_checker_.CalledOnValidThread());
905 // Only send an event if this is due to a cycle ending and this cycle 921 // Only send an event if this is due to a cycle ending and this cycle
906 // concludes a canonical "sync" process; that is, based on what is known 922 // concludes a canonical "sync" process; that is, based on what is known
907 // locally we are "all happy" and up-to-date. There may be new changes on 923 // locally we are "all happy" and up-to-date. There may be new changes on
908 // the server, but we'll get them on a subsequent sync. 924 // the server, but we'll get them on a subsequent sync.
909 // 925 //
910 // Notifications are sent at the end of every sync cycle, regardless of 926 // Notifications are sent at the end of every sync cycle, regardless of
911 // whether we should sync again. 927 // whether we should sync again.
912 if (event.what_happened == SyncCycleEvent::SYNC_CYCLE_ENDED) { 928 if (event.what_happened == SyncCycleEvent::SYNC_CYCLE_ENDED) {
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 int SyncManagerImpl::GetDefaultNudgeDelay() { 1152 int SyncManagerImpl::GetDefaultNudgeDelay() {
1137 return kDefaultNudgeDelayMilliseconds; 1153 return kDefaultNudgeDelayMilliseconds;
1138 } 1154 }
1139 1155
1140 // static. 1156 // static.
1141 int SyncManagerImpl::GetPreferencesNudgeDelay() { 1157 int SyncManagerImpl::GetPreferencesNudgeDelay() {
1142 return kPreferencesNudgeDelayMilliseconds; 1158 return kPreferencesNudgeDelayMilliseconds;
1143 } 1159 }
1144 1160
1145 } // namespace syncer 1161 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/sync_manager_impl.h ('k') | sync/sessions/model_type_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698