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

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

Issue 6272025: Part 2 of repairing regressions to my old clang check plugins so Nico can (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Copyright 2011 Created 9 years, 10 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/linked_ptr.h" 10 #include "base/linked_ptr.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 virtual void OnReceivedLongPollIntervalUpdate( 79 virtual void OnReceivedLongPollIntervalUpdate(
80 const base::TimeDelta& new_interval); 80 const base::TimeDelta& new_interval);
81 virtual void OnShouldStopSyncingPermanently(); 81 virtual void OnShouldStopSyncingPermanently();
82 82
83 private: 83 private:
84 friend class SyncerThread2Test; 84 friend class SyncerThread2Test;
85 85
86 // State pertaining to exponential backoff or throttling periods. 86 // State pertaining to exponential backoff or throttling periods.
87 struct WaitInterval; 87 struct WaitInterval;
88 88
89 // An enum used to describe jobs for scheduling purposes.
90 enum SyncSessionJobPurpose {
91 // Our poll timer schedules POLL jobs periodically based on a server
92 // assigned poll interval.
93 POLL,
94 // A nudge task can come from a variety of components needing to force
95 // a sync. The source is inferable from |session.source()|.
96 NUDGE,
97 // Typically used for fetching updates for a subset of the enabled types
98 // during initial sync or reconfiguration. We don't run all steps of
99 // the sync cycle for these (e.g. CleanupDisabledTypes is skipped).
100 CONFIGURATION,
101 };
102
89 // Internal state for every sync task that is scheduled. 103 // Internal state for every sync task that is scheduled.
90 struct SyncSessionJob { 104 struct SyncSessionJob;
91 // An enum used to describe jobs for scheduling purposes.
92 enum Purpose {
93 // Our poll timer schedules POLL jobs periodically based on a server
94 // assigned poll interval.
95 POLL,
96 // A nudge task can come from a variety of components needing to force
97 // a sync. The source is inferable from |session.source()|.
98 NUDGE,
99 // Typically used for fetching updates for a subset of the enabled types
100 // during initial sync or reconfiguration. We don't run all steps of
101 // the sync cycle for these (e.g. CleanupDisabledTypes is skipped).
102 CONFIGURATION,
103 };
104
105 Purpose purpose;
106 base::TimeTicks scheduled_start;
107 linked_ptr<sessions::SyncSession> session;
108 };
109 105
110 // A component used to get time delays associated with exponential backoff. 106 // A component used to get time delays associated with exponential backoff.
111 // Encapsulated into a class to facilitate testing. 107 // Encapsulated into a class to facilitate testing.
112 class DelayProvider { 108 class DelayProvider {
113 public: 109 public:
114 DelayProvider(); 110 DelayProvider();
115 virtual base::TimeDelta GetDelay(const base::TimeDelta& last_delay); 111 virtual base::TimeDelta GetDelay(const base::TimeDelta& last_delay);
116 virtual ~DelayProvider(); 112 virtual ~DelayProvider();
117 private: 113 private:
118 DISALLOW_COPY_AND_ASSIGN(DelayProvider); 114 DISALLOW_COPY_AND_ASSIGN(DelayProvider);
119 }; 115 };
120 116
121 // Helper to assemble a job and post a delayed task to sync. 117 // Helper to assemble a job and post a delayed task to sync.
122 void ScheduleSyncSessionJob(const base::TimeDelta& delay, 118 void ScheduleSyncSessionJob(const base::TimeDelta& delay,
123 SyncSessionJob::Purpose purpose, 119 SyncSessionJobPurpose purpose,
124 sessions::SyncSession* session); 120 sessions::SyncSession* session);
125 121
126 // Invoke the Syncer to perform a sync. 122 // Invoke the Syncer to perform a sync.
127 void DoSyncSessionJob(const SyncSessionJob& job); 123 void DoSyncSessionJob(const SyncSessionJob& job);
128 124
129 // Called after the Syncer has performed the sync represented by |job|, to 125 // Called after the Syncer has performed the sync represented by |job|, to
130 // reset our state. 126 // reset our state.
131 void FinishSyncSessionJob(const SyncSessionJob& job); 127 void FinishSyncSessionJob(const SyncSessionJob& job);
132 128
133 // Helper to FinishSyncSessionJob to schedule the next sync operation. 129 // Helper to FinishSyncSessionJob to schedule the next sync operation.
134 void ScheduleNextSync(const SyncSessionJob& old_job); 130 void ScheduleNextSync(const SyncSessionJob& old_job);
135 131
136 // Helper to configure polling intervals. Used by Start and ScheduleNextSync. 132 // Helper to configure polling intervals. Used by Start and ScheduleNextSync.
137 void AdjustPolling(const SyncSessionJob* old_job); 133 void AdjustPolling(const SyncSessionJob* old_job);
138 134
139 // Helper to ScheduleNextSync in case of consecutive sync errors. 135 // Helper to ScheduleNextSync in case of consecutive sync errors.
140 void HandleConsecutiveContinuationError(const SyncSessionJob& old_job); 136 void HandleConsecutiveContinuationError(const SyncSessionJob& old_job);
141 137
142 // Determines if it is legal to run a sync job for |purpose| at 138 // Determines if it is legal to run a sync job for |purpose| at
143 // |scheduled_start|. This checks current operational mode, backoff or 139 // |scheduled_start|. This checks current operational mode, backoff or
144 // throttling, freshness (so we don't make redundant syncs), and connection. 140 // throttling, freshness (so we don't make redundant syncs), and connection.
145 bool ShouldRunJob(SyncSessionJob::Purpose purpose, 141 bool ShouldRunJob(SyncSessionJobPurpose purpose,
146 const base::TimeTicks& scheduled_start); 142 const base::TimeTicks& scheduled_start);
147 143
148 // 'Impl' here refers to real implementation of public functions, running on 144 // 'Impl' here refers to real implementation of public functions, running on
149 // |thread_|. 145 // |thread_|.
150 void StartImpl(Mode mode); 146 void StartImpl(Mode mode);
151 void ScheduleNudgeImpl(const base::TimeDelta& delay, 147 void ScheduleNudgeImpl(const base::TimeDelta& delay,
152 NudgeSource source, 148 NudgeSource source,
153 const syncable::ModelTypeBitSet& model_types); 149 const syncable::ModelTypeBitSet& model_types);
154 void ScheduleConfigImpl(const base::TimeDelta& delay, 150 void ScheduleConfigImpl(const base::TimeDelta& delay,
155 const ModelSafeRoutingInfo& routing_info, 151 const ModelSafeRoutingInfo& routing_info,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 206
211 } // namespace s3 207 } // namespace s3
212 208
213 } // namespace browser_sync 209 } // namespace browser_sync
214 210
215 // The SyncerThread manages its own internal thread and thus outlives it. We 211 // The SyncerThread manages its own internal thread and thus outlives it. We
216 // don't need refcounting for posting tasks to this internal thread. 212 // don't need refcounting for posting tasks to this internal thread.
217 DISABLE_RUNNABLE_METHOD_REFCOUNT(browser_sync::s3::SyncerThread); 213 DISABLE_RUNNABLE_METHOD_REFCOUNT(browser_sync::s3::SyncerThread);
218 214
219 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD2_H_ 215 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNCER_THREAD2_H_
OLDNEW
« no previous file with comments | « chrome/browser/speech/speech_input_bubble.cc ('k') | chrome/browser/sync/engine/syncer_thread2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698