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

Side by Side Diff: chrome/browser/sync/engine/syncer_thread2.h

Issue 6812004: sync: Make nudge + config jobs reliable in SyncerThread2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing a typo. Created 9 years, 8 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
OLDNEW
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 // A class to run the syncer on a thread. 5 // A class to run the syncer on a thread.
6 #ifndef CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD2_H_ 6 #ifndef CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD2_H_
7 #define CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD2_H_ 7 #define CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD2_H_
8 #pragma once 8 #pragma once
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 25 matching lines...) Expand all
36 // In this mode, the thread only performs configuration tasks. This is 36 // In this mode, the thread only performs configuration tasks. This is
37 // designed to make the case where we want to download updates for a 37 // designed to make the case where we want to download updates for a
38 // specific type only, and not continue syncing until we are moved into 38 // specific type only, and not continue syncing until we are moved into
39 // normal mode. 39 // normal mode.
40 CONFIGURATION_MODE, 40 CONFIGURATION_MODE,
41 // Resumes polling and allows nudges, drops configuration tasks. Runs 41 // Resumes polling and allows nudges, drops configuration tasks. Runs
42 // through entire sync cycle. 42 // through entire sync cycle.
43 NORMAL_MODE, 43 NORMAL_MODE,
44 }; 44 };
45 45
46 enum JobProcessDecision {
47 // Indicates we should continue with the current job.
48 CONTINUE,
49 // Indicates that we should save it to be processed later.
50 SAVE,
51 // Indicates we should drop this job.
52 DROP,
53 };
54
46 // Takes ownership of both |context| and |syncer|. 55 // Takes ownership of both |context| and |syncer|.
47 SyncerThread(sessions::SyncSessionContext* context, Syncer* syncer); 56 SyncerThread(sessions::SyncSessionContext* context, Syncer* syncer);
48 virtual ~SyncerThread(); 57 virtual ~SyncerThread();
49 58
50 typedef Callback0::Type ModeChangeCallback; 59 typedef Callback0::Type ModeChangeCallback;
51 60
52 // Change the mode of operation. 61 // Change the mode of operation.
53 // We don't use a lock when changing modes, so we won't cause currently 62 // We don't use a lock when changing modes, so we won't cause currently
54 // scheduled jobs to adhere to the new mode. We could protect it, but it 63 // scheduled jobs to adhere to the new mode. We could protect it, but it
55 // doesn't buy very much as a) a session could already be in progress and it 64 // doesn't buy very much as a) a session could already be in progress and it
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 163
155 // Helper to FinishSyncSessionJob to schedule the next sync operation. 164 // Helper to FinishSyncSessionJob to schedule the next sync operation.
156 void ScheduleNextSync(const SyncSessionJob& old_job); 165 void ScheduleNextSync(const SyncSessionJob& old_job);
157 166
158 // Helper to configure polling intervals. Used by Start and ScheduleNextSync. 167 // Helper to configure polling intervals. Used by Start and ScheduleNextSync.
159 void AdjustPolling(const SyncSessionJob* old_job); 168 void AdjustPolling(const SyncSessionJob* old_job);
160 169
161 // Helper to ScheduleNextSync in case of consecutive sync errors. 170 // Helper to ScheduleNextSync in case of consecutive sync errors.
162 void HandleConsecutiveContinuationError(const SyncSessionJob& old_job); 171 void HandleConsecutiveContinuationError(const SyncSessionJob& old_job);
163 172
164 // Determines if it is legal to run a sync job for |purpose| at 173 // Determines if it is legal to run a sync |job|.
165 // |scheduled_start|. This checks current operational mode, backoff or 174 // This checks current operational mode, backoff or
166 // throttling, freshness (so we don't make redundant syncs), and connection. 175 // throttling, freshness (so we don't make redundant syncs), and connection.
167 bool ShouldRunJob(SyncSessionJobPurpose purpose, 176 bool ShouldRunJob(const SyncSessionJob& job);
168 const base::TimeTicks& scheduled_start); 177
178 // Decide on whether to run, save or discard the job when we are in
179 // back off mode.
180 JobProcessDecision DecideOnJobWhileBackingOff(const SyncSessionJob& job);
181
182 // Decide whether we should run, save or discard the job.
183 JobProcessDecision ProcessJob(const SyncSessionJob& job);
169 184
170 // 'Impl' here refers to real implementation of public functions, running on 185 // 'Impl' here refers to real implementation of public functions, running on
171 // |thread_|. 186 // |thread_|.
172 void StartImpl(Mode mode, linked_ptr<ModeChangeCallback> callback); 187 void StartImpl(Mode mode, linked_ptr<ModeChangeCallback> callback);
173 void ScheduleNudgeImpl( 188 void ScheduleNudgeImpl(
174 const base::TimeDelta& delay, 189 const base::TimeDelta& delay,
175 NudgeSource source, 190 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source,
176 const syncable::ModelTypePayloadMap& types_with_payloads, 191 const syncable::ModelTypePayloadMap& types_with_payloads,
177 const tracked_objects::Location& nudge_location); 192 bool is_canary_job, const tracked_objects::Location& nudge_location);
178 void ScheduleConfigImpl(const ModelSafeRoutingInfo& routing_info, 193 void ScheduleConfigImpl(const ModelSafeRoutingInfo& routing_info,
179 const std::vector<ModelSafeWorker*>& workers); 194 const std::vector<ModelSafeWorker*>& workers,
195 const sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source);
180 void ScheduleClearUserDataImpl(); 196 void ScheduleClearUserDataImpl();
181 197
182 // Returns true if the client is currently in exponential backoff. 198 // Returns true if the client is currently in exponential backoff.
183 bool IsBackingOff() const; 199 bool IsBackingOff() const;
184 200
185 // Helper to signal all listeners registered with |session_context_|. 201 // Helper to signal all listeners registered with |session_context_|.
186 void Notify(SyncEngineEvent::EventCause cause); 202 void Notify(SyncEngineEvent::EventCause cause);
187 203
188 // Callback to change backoff state. 204 // Callback to change backoff state.
189 void DoCanaryJob(); 205 void DoCanaryJob();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // Current wait state. Null if we're not in backoff and not throttled. 252 // Current wait state. Null if we're not in backoff and not throttled.
237 scoped_ptr<WaitInterval> wait_interval_; 253 scoped_ptr<WaitInterval> wait_interval_;
238 254
239 scoped_ptr<DelayProvider> delay_provider_; 255 scoped_ptr<DelayProvider> delay_provider_;
240 256
241 // Invoked to run through the sync cycle. 257 // Invoked to run through the sync cycle.
242 scoped_ptr<Syncer> syncer_; 258 scoped_ptr<Syncer> syncer_;
243 259
244 scoped_ptr<sessions::SyncSessionContext> session_context_; 260 scoped_ptr<sessions::SyncSessionContext> session_context_;
245 261
262 bool saved_nudge_;
263 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource saved_source_;
264
246 DISALLOW_COPY_AND_ASSIGN(SyncerThread); 265 DISALLOW_COPY_AND_ASSIGN(SyncerThread);
247 }; 266 };
248 267
249 } // namespace s3 268 } // namespace s3
250 269
251 } // namespace browser_sync 270 } // namespace browser_sync
252 271
253 // The SyncerThread manages its own internal thread and thus outlives it. We 272 // The SyncerThread manages its own internal thread and thus outlives it. We
254 // don't need refcounting for posting tasks to this internal thread. 273 // don't need refcounting for posting tasks to this internal thread.
255 DISABLE_RUNNABLE_METHOD_REFCOUNT(browser_sync::s3::SyncerThread); 274 DISABLE_RUNNABLE_METHOD_REFCOUNT(browser_sync::s3::SyncerThread);
256 275
257 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD2_H_ 276 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD2_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/engine/syncer_thread2.cc » ('j') | chrome/browser/sync/engine/syncer_thread2.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698