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

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

Issue 9348036: Trim code from sync's ServerConnectionManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: small updates Created 8 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) 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 // A class to schedule syncer tasks intelligently. 5 // A class to schedule syncer tasks intelligently.
6 #ifndef CHROME_BROWSER_SYNC_ENGINE_SYNC_SCHEDULER_H_ 6 #ifndef CHROME_BROWSER_SYNC_ENGINE_SYNC_SCHEDULER_H_
7 #define CHROME_BROWSER_SYNC_ENGINE_SYNC_SCHEDULER_H_ 7 #define CHROME_BROWSER_SYNC_ENGINE_SYNC_SCHEDULER_H_
8 #pragma once 8 #pragma once
9 9
10 #include <string> 10 #include <string>
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // Change status of notifications in the SyncSessionContext. 101 // Change status of notifications in the SyncSessionContext.
102 void set_notifications_enabled(bool notifications_enabled); 102 void set_notifications_enabled(bool notifications_enabled);
103 103
104 base::TimeDelta sessions_commit_delay() const; 104 base::TimeDelta sessions_commit_delay() const;
105 105
106 // DDOS avoidance function. Calculates how long we should wait before trying 106 // DDOS avoidance function. Calculates how long we should wait before trying
107 // again after a failed sync attempt, where the last delay was |base_delay|. 107 // again after a failed sync attempt, where the last delay was |base_delay|.
108 // TODO(tim): Look at URLRequestThrottlerEntryInterface. 108 // TODO(tim): Look at URLRequestThrottlerEntryInterface.
109 static base::TimeDelta GetRecommendedDelay(const base::TimeDelta& base_delay); 109 static base::TimeDelta GetRecommendedDelay(const base::TimeDelta& base_delay);
110 110
111 // Called when credentials are updated by the user.
112 void OnCredentialsUpdated();
113
114 // Called when the network layer detects a connection status change.
115 void OnConnectionStatusChange();
116
117 // SyncSession::Delegate implementation. 111 // SyncSession::Delegate implementation.
118 virtual void OnSilencedUntil( 112 virtual void OnSilencedUntil(
119 const base::TimeTicks& silenced_until) OVERRIDE; 113 const base::TimeTicks& silenced_until) OVERRIDE;
120 virtual bool IsSyncingCurrentlySilenced() OVERRIDE; 114 virtual bool IsSyncingCurrentlySilenced() OVERRIDE;
121 virtual void OnReceivedShortPollIntervalUpdate( 115 virtual void OnReceivedShortPollIntervalUpdate(
122 const base::TimeDelta& new_interval) OVERRIDE; 116 const base::TimeDelta& new_interval) OVERRIDE;
123 virtual void OnReceivedLongPollIntervalUpdate( 117 virtual void OnReceivedLongPollIntervalUpdate(
124 const base::TimeDelta& new_interval) OVERRIDE; 118 const base::TimeDelta& new_interval) OVERRIDE;
125 virtual void OnReceivedSessionsCommitDelay( 119 virtual void OnReceivedSessionsCommitDelay(
126 const base::TimeDelta& new_delay) OVERRIDE; 120 const base::TimeDelta& new_delay) OVERRIDE;
127 virtual void OnShouldStopSyncingPermanently() OVERRIDE; 121 virtual void OnShouldStopSyncingPermanently() OVERRIDE;
128 virtual void OnSyncProtocolError( 122 virtual void OnSyncProtocolError(
129 const sessions::SyncSessionSnapshot& snapshot) OVERRIDE; 123 const sessions::SyncSessionSnapshot& snapshot) OVERRIDE;
130 124
125 // Called when the root cause of the current connection error is fixed.
126 void OnServerConnectionErrorFixed();
127
131 private: 128 private:
132 enum JobProcessDecision { 129 enum JobProcessDecision {
133 // Indicates we should continue with the current job. 130 // Indicates we should continue with the current job.
134 CONTINUE, 131 CONTINUE,
135 // Indicates that we should save it to be processed later. 132 // Indicates that we should save it to be processed later.
136 SAVE, 133 SAVE,
137 // Indicates we should drop this job. 134 // Indicates we should drop this job.
138 DROP, 135 DROP,
139 }; 136 };
140 137
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 317
321 // Callback to change backoff state. 318 // Callback to change backoff state.
322 void DoCanaryJob(); 319 void DoCanaryJob();
323 void Unthrottle(); 320 void Unthrottle();
324 321
325 // Executes the pending job. Called whenever an event occurs that may 322 // Executes the pending job. Called whenever an event occurs that may
326 // change conditions permitting a job to run. Like when network connection is 323 // change conditions permitting a job to run. Like when network connection is
327 // re-established, mode changes etc. 324 // re-established, mode changes etc.
328 void DoPendingJobIfPossible(bool is_canary_job); 325 void DoPendingJobIfPossible(bool is_canary_job);
329 326
330 // Called when the root cause of the current connection error is fixed.
331 void OnServerConnectionErrorFixed();
332
333 // The pointer is owned by the caller. 327 // The pointer is owned by the caller.
334 browser_sync::sessions::SyncSession* CreateSyncSession( 328 browser_sync::sessions::SyncSession* CreateSyncSession(
335 const browser_sync::sessions::SyncSourceInfo& info); 329 const browser_sync::sessions::SyncSourceInfo& info);
336 330
337 // Creates a session for a poll and performs the sync. 331 // Creates a session for a poll and performs the sync.
338 void PollTimerCallback(); 332 void PollTimerCallback();
339 333
340 // Assign |start| and |end| to appropriate SyncerStep values for the 334 // Assign |start| and |end| to appropriate SyncerStep values for the
341 // specified |purpose|. 335 // specified |purpose|.
342 void SetSyncerStepsForPurpose(SyncSessionJob::SyncSessionJobPurpose purpose, 336 void SetSyncerStepsForPurpose(SyncSessionJob::SyncSessionJobPurpose purpose,
343 SyncerStep* start, 337 SyncerStep* start,
344 SyncerStep* end); 338 SyncerStep* end);
345 339
346 // Used to update |server_connection_ok_|, see below.
347 void UpdateServerConnectionManagerStatus(
348 HttpResponse::ServerConnectionCode code);
349
350 // Called once the first time thread_ is started to broadcast an initial 340 // Called once the first time thread_ is started to broadcast an initial
351 // session snapshot containing data like initial_sync_ended. Important when 341 // session snapshot containing data like initial_sync_ended. Important when
352 // the client starts up and does not need to perform an initial sync. 342 // the client starts up and does not need to perform an initial sync.
353 void SendInitialSnapshot(); 343 void SendInitialSnapshot();
354 344
355 virtual void OnActionableError(const sessions::SyncSessionSnapshot& snapshot); 345 virtual void OnActionableError(const sessions::SyncSessionSnapshot& snapshot);
356 346
357 base::WeakPtrFactory<SyncScheduler> weak_ptr_factory_; 347 base::WeakPtrFactory<SyncScheduler> weak_ptr_factory_;
358 348
359 // A second factory specially for weak_handle_this_, to allow the handle 349 // A second factory specially for weak_handle_this_, to allow the handle
(...skipping 24 matching lines...) Expand all
384 // Periodic timer for polling. See AdjustPolling. 374 // Periodic timer for polling. See AdjustPolling.
385 base::RepeatingTimer<SyncScheduler> poll_timer_; 375 base::RepeatingTimer<SyncScheduler> poll_timer_;
386 376
387 // The mode of operation. 377 // The mode of operation.
388 Mode mode_; 378 Mode mode_;
389 379
390 // TODO(tim): Bug 26339. This needs to track more than just time I think, 380 // TODO(tim): Bug 26339. This needs to track more than just time I think,
391 // since the nudges could be for different types. Current impl doesn't care. 381 // since the nudges could be for different types. Current impl doesn't care.
392 base::TimeTicks last_sync_session_end_time_; 382 base::TimeTicks last_sync_session_end_time_;
393 383
394 // Have we observed a valid server connection?
395 bool server_connection_ok_;
396
397 // The latest connection code we got while trying to connect.
398 HttpResponse::ServerConnectionCode connection_code_;
399
400 // Tracks in-flight nudges so we can coalesce. 384 // Tracks in-flight nudges so we can coalesce.
401 scoped_ptr<SyncSessionJob> pending_nudge_; 385 scoped_ptr<SyncSessionJob> pending_nudge_;
402 386
403 // Current wait state. Null if we're not in backoff and not throttled. 387 // Current wait state. Null if we're not in backoff and not throttled.
404 scoped_ptr<WaitInterval> wait_interval_; 388 scoped_ptr<WaitInterval> wait_interval_;
405 389
406 scoped_ptr<DelayProvider> delay_provider_; 390 scoped_ptr<DelayProvider> delay_provider_;
407 391
408 // Invoked to run through the sync cycle. 392 // Invoked to run through the sync cycle.
409 scoped_ptr<Syncer> syncer_; 393 scoped_ptr<Syncer> syncer_;
410 394
411 scoped_ptr<sessions::SyncSessionContext> session_context_; 395 scoped_ptr<sessions::SyncSessionContext> session_context_;
412 396
413 DISALLOW_COPY_AND_ASSIGN(SyncScheduler); 397 DISALLOW_COPY_AND_ASSIGN(SyncScheduler);
414 }; 398 };
415 399
416 } // namespace browser_sync 400 } // namespace browser_sync
417 401
418 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNC_SCHEDULER_H_ 402 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNC_SCHEDULER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698