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

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

Issue 478853003: [Sync] Have bookmarks use a slower nudge delay to better handle automated writes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 4 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/internal_api/sync_manager_impl_unittest.cc » ('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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 using sessions::SyncSessionContext; 57 using sessions::SyncSessionContext;
58 using syncable::ImmutableWriteTransactionInfo; 58 using syncable::ImmutableWriteTransactionInfo;
59 using syncable::SPECIFICS; 59 using syncable::SPECIFICS;
60 using syncable::UNIQUE_POSITION; 60 using syncable::UNIQUE_POSITION;
61 61
62 namespace { 62 namespace {
63 63
64 // Delays for syncer nudges. 64 // Delays for syncer nudges.
65 static const int kDefaultNudgeDelayMilliseconds = 200; 65 static const int kDefaultNudgeDelayMilliseconds = 200;
66 static const int kPreferencesNudgeDelayMilliseconds = 2000; 66 static const int kSlowNudgeDelayMilliseconds = 2000;
67 static const int kSyncRefreshDelayMsec = 500; 67 static const int kSyncRefreshDelayMsec = 500;
68 static const int kSyncSchedulerDelayMsec = 250; 68 static const int kSyncSchedulerDelayMsec = 250;
69 69
70 GetUpdatesCallerInfo::GetUpdatesSource GetSourceFromReason( 70 GetUpdatesCallerInfo::GetUpdatesSource GetSourceFromReason(
71 ConfigureReason reason) { 71 ConfigureReason reason) {
72 switch (reason) { 72 switch (reason) {
73 case CONFIGURE_REASON_RECONFIGURATION: 73 case CONFIGURE_REASON_RECONFIGURATION:
74 return GetUpdatesCallerInfo::RECONFIGURATION; 74 return GetUpdatesCallerInfo::RECONFIGURATION;
75 case CONFIGURE_REASON_MIGRATION: 75 case CONFIGURE_REASON_MIGRATION:
76 return GetUpdatesCallerInfo::MIGRATION; 76 return GetUpdatesCallerInfo::MIGRATION;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 // The datatype does not use one of the predefined wait times but defines 114 // The datatype does not use one of the predefined wait times but defines
115 // its own wait time logic for nudge. 115 // its own wait time logic for nudge.
116 CUSTOM, 116 CUSTOM,
117 }; 117 };
118 118
119 static NudgeDelayStrategy GetNudgeDelayStrategy(const ModelType& type) { 119 static NudgeDelayStrategy GetNudgeDelayStrategy(const ModelType& type) {
120 switch (type) { 120 switch (type) {
121 case AUTOFILL: 121 case AUTOFILL:
122 return ACCOMPANY_ONLY; 122 return ACCOMPANY_ONLY;
123 case BOOKMARKS:
123 case PREFERENCES: 124 case PREFERENCES:
124 case SESSIONS: 125 case SESSIONS:
125 case FAVICON_IMAGES: 126 case FAVICON_IMAGES:
126 case FAVICON_TRACKING: 127 case FAVICON_TRACKING:
127 return CUSTOM; 128 return CUSTOM;
128 default: 129 default:
129 return IMMEDIATE; 130 return IMMEDIATE;
130 } 131 }
131 } 132 }
132 133
133 static TimeDelta GetNudgeDelayTimeDeltaFromType( 134 static TimeDelta GetNudgeDelayTimeDeltaFromType(
134 const NudgeDelayStrategy& delay_type, const ModelType& model_type, 135 const NudgeDelayStrategy& delay_type, const ModelType& model_type,
135 const SyncManagerImpl* core) { 136 const SyncManagerImpl* core) {
136 CHECK(core); 137 CHECK(core);
137 TimeDelta delay = TimeDelta::FromMilliseconds( 138 TimeDelta delay = TimeDelta::FromMilliseconds(
138 kDefaultNudgeDelayMilliseconds); 139 kDefaultNudgeDelayMilliseconds);
139 switch (delay_type) { 140 switch (delay_type) {
140 case IMMEDIATE: 141 case IMMEDIATE:
141 delay = TimeDelta::FromMilliseconds( 142 delay = TimeDelta::FromMilliseconds(
142 kDefaultNudgeDelayMilliseconds); 143 kDefaultNudgeDelayMilliseconds);
143 break; 144 break;
144 case ACCOMPANY_ONLY: 145 case ACCOMPANY_ONLY:
145 delay = TimeDelta::FromSeconds(kDefaultShortPollIntervalSeconds); 146 delay = TimeDelta::FromSeconds(kDefaultShortPollIntervalSeconds);
146 break; 147 break;
147 case CUSTOM: 148 case CUSTOM:
148 switch (model_type) { 149 switch (model_type) {
150 case BOOKMARKS:
149 case PREFERENCES: 151 case PREFERENCES:
150 delay = TimeDelta::FromMilliseconds( 152 delay = TimeDelta::FromMilliseconds(kSlowNudgeDelayMilliseconds);
151 kPreferencesNudgeDelayMilliseconds);
152 break; 153 break;
153 case SESSIONS: 154 case SESSIONS:
154 case FAVICON_IMAGES: 155 case FAVICON_IMAGES:
155 case FAVICON_TRACKING: 156 case FAVICON_TRACKING:
156 delay = core->scheduler()->GetSessionsCommitDelay(); 157 delay = core->scheduler()->GetSessionsCommitDelay();
157 break; 158 break;
158 default: 159 default:
159 NOTREACHED(); 160 NOTREACHED();
160 } 161 }
161 break; 162 break;
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 void SyncManagerImpl::RequestEmitDebugInfo() { 1143 void SyncManagerImpl::RequestEmitDebugInfo() {
1143 model_type_registry_->RequestEmitDebugInfo(); 1144 model_type_registry_->RequestEmitDebugInfo();
1144 } 1145 }
1145 1146
1146 // static. 1147 // static.
1147 int SyncManagerImpl::GetDefaultNudgeDelay() { 1148 int SyncManagerImpl::GetDefaultNudgeDelay() {
1148 return kDefaultNudgeDelayMilliseconds; 1149 return kDefaultNudgeDelayMilliseconds;
1149 } 1150 }
1150 1151
1151 // static. 1152 // static.
1152 int SyncManagerImpl::GetPreferencesNudgeDelay() { 1153 int SyncManagerImpl::GetSlowNudgeDelay() {
1153 return kPreferencesNudgeDelayMilliseconds; 1154 return kSlowNudgeDelayMilliseconds;
1154 } 1155 }
1155 1156
1156 } // namespace syncer 1157 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/sync_manager_impl.h ('k') | sync/internal_api/sync_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698