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

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

Issue 7604019: [Sync] Add client-side plumbing for server control of sessions commit delay (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error and address comments Created 9 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 | « no previous file | chrome/browser/sync/engine/sync_scheduler.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) 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 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>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/compiler_specific.h"
13 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
14 #include "base/memory/linked_ptr.h" 15 #include "base/memory/linked_ptr.h"
15 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
16 #include "base/observer_list.h" 17 #include "base/observer_list.h"
17 #include "base/task.h" 18 #include "base/task.h"
18 #include "base/time.h" 19 #include "base/time.h"
19 #include "base/timer.h" 20 #include "base/timer.h"
20 #include "chrome/browser/sync/engine/configure_reason.h" 21 #include "chrome/browser/sync/engine/configure_reason.h"
21 #include "chrome/browser/sync/engine/nudge_source.h" 22 #include "chrome/browser/sync/engine/nudge_source.h"
22 #include "chrome/browser/sync/engine/polling_constants.h" 23 #include "chrome/browser/sync/engine/polling_constants.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 const syncable::ModelTypePayloadMap& types_with_payloads, 92 const syncable::ModelTypePayloadMap& types_with_payloads,
92 const tracked_objects::Location& nudge_location); 93 const tracked_objects::Location& nudge_location);
93 void ScheduleConfig(const syncable::ModelTypeBitSet& types, 94 void ScheduleConfig(const syncable::ModelTypeBitSet& types,
94 sync_api::ConfigureReason reason); 95 sync_api::ConfigureReason reason);
95 void ScheduleClearUserData(); 96 void ScheduleClearUserData();
96 void ScheduleCleanupDisabledTypes(); 97 void ScheduleCleanupDisabledTypes();
97 98
98 // Change status of notifications in the SyncSessionContext. 99 // Change status of notifications in the SyncSessionContext.
99 void set_notifications_enabled(bool notifications_enabled); 100 void set_notifications_enabled(bool notifications_enabled);
100 101
102 base::TimeDelta sessions_commit_delay() const;
103
101 // DDOS avoidance function. Calculates how long we should wait before trying 104 // DDOS avoidance function. Calculates how long we should wait before trying
102 // again after a failed sync attempt, where the last delay was |base_delay|. 105 // again after a failed sync attempt, where the last delay was |base_delay|.
103 // TODO(tim): Look at URLRequestThrottlerEntryInterface. 106 // TODO(tim): Look at URLRequestThrottlerEntryInterface.
104 static base::TimeDelta GetRecommendedDelay(const base::TimeDelta& base_delay); 107 static base::TimeDelta GetRecommendedDelay(const base::TimeDelta& base_delay);
105 108
106 // SyncSession::Delegate implementation. 109 // SyncSession::Delegate implementation.
107 virtual void OnSilencedUntil(const base::TimeTicks& silenced_until); 110 virtual void OnSilencedUntil(
108 virtual bool IsSyncingCurrentlySilenced(); 111 const base::TimeTicks& silenced_until) OVERRIDE;
112 virtual bool IsSyncingCurrentlySilenced() OVERRIDE;
109 virtual void OnReceivedShortPollIntervalUpdate( 113 virtual void OnReceivedShortPollIntervalUpdate(
110 const base::TimeDelta& new_interval); 114 const base::TimeDelta& new_interval) OVERRIDE;
111 virtual void OnReceivedLongPollIntervalUpdate( 115 virtual void OnReceivedLongPollIntervalUpdate(
112 const base::TimeDelta& new_interval); 116 const base::TimeDelta& new_interval) OVERRIDE;
113 virtual void OnShouldStopSyncingPermanently(); 117 virtual void OnReceivedSessionsCommitDelay(
118 const base::TimeDelta& new_delay) OVERRIDE;
119 virtual void OnShouldStopSyncingPermanently() OVERRIDE;
114 120
115 // ServerConnectionEventListener implementation. 121 // ServerConnectionEventListener implementation.
116 // TODO(tim): schedule a nudge when valid connection detected? in 1 minute? 122 // TODO(tim): schedule a nudge when valid connection detected? in 1 minute?
117 virtual void OnServerConnectionEvent(const ServerConnectionEvent& event); 123 virtual void OnServerConnectionEvent(
124 const ServerConnectionEvent& event) OVERRIDE;
118 125
119 private: 126 private:
120 enum JobProcessDecision { 127 enum JobProcessDecision {
121 // Indicates we should continue with the current job. 128 // Indicates we should continue with the current job.
122 CONTINUE, 129 CONTINUE,
123 // Indicates that we should save it to be processed later. 130 // Indicates that we should save it to be processed later.
124 SAVE, 131 SAVE,
125 // Indicates we should drop this job. 132 // Indicates we should drop this job.
126 DROP, 133 DROP,
127 }; 134 };
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 MessageLoop* const sync_loop_; 359 MessageLoop* const sync_loop_;
353 360
354 // Set in Start(), unset in Stop(). 361 // Set in Start(), unset in Stop().
355 bool started_; 362 bool started_;
356 363
357 // Modifiable versions of kDefaultLongPollIntervalSeconds which can be 364 // Modifiable versions of kDefaultLongPollIntervalSeconds which can be
358 // updated by the server. 365 // updated by the server.
359 base::TimeDelta syncer_short_poll_interval_seconds_; 366 base::TimeDelta syncer_short_poll_interval_seconds_;
360 base::TimeDelta syncer_long_poll_interval_seconds_; 367 base::TimeDelta syncer_long_poll_interval_seconds_;
361 368
369 // Server-tweakable sessions commit delay.
370 base::TimeDelta sessions_commit_delay_;
371
362 // Periodic timer for polling. See AdjustPolling. 372 // Periodic timer for polling. See AdjustPolling.
363 base::RepeatingTimer<SyncScheduler> poll_timer_; 373 base::RepeatingTimer<SyncScheduler> poll_timer_;
364 374
365 // The mode of operation. 375 // The mode of operation.
366 Mode mode_; 376 Mode mode_;
367 377
368 // TODO(tim): Bug 26339. This needs to track more than just time I think, 378 // TODO(tim): Bug 26339. This needs to track more than just time I think,
369 // since the nudges could be for different types. Current impl doesn't care. 379 // since the nudges could be for different types. Current impl doesn't care.
370 base::TimeTicks last_sync_session_end_time_; 380 base::TimeTicks last_sync_session_end_time_;
371 381
(...skipping 12 matching lines...) Expand all
384 scoped_ptr<Syncer> syncer_; 394 scoped_ptr<Syncer> syncer_;
385 395
386 scoped_ptr<sessions::SyncSessionContext> session_context_; 396 scoped_ptr<sessions::SyncSessionContext> session_context_;
387 397
388 DISALLOW_COPY_AND_ASSIGN(SyncScheduler); 398 DISALLOW_COPY_AND_ASSIGN(SyncScheduler);
389 }; 399 };
390 400
391 } // namespace browser_sync 401 } // namespace browser_sync
392 402
393 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNC_SCHEDULER_H_ 403 #endif // CHROME_BROWSER_SYNC_ENGINE_SYNC_SCHEDULER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/sync/engine/sync_scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698