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

Side by Side Diff: sync/engine/sync_scheduler_impl.h

Issue 10825439: sync: remove buggy freshness condition in SyncSchedulerImpl add defensive DCHECKs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: FIX Created 8 years, 3 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 | sync/engine/sync_scheduler_impl.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 #ifndef SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ 5 #ifndef SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_
6 #define SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ 6 #define SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_
7 7
8 #include <map>
8 #include <string> 9 #include <string>
9 10
10 #include "base/callback.h" 11 #include "base/callback.h"
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
13 #include "base/memory/linked_ptr.h" 14 #include "base/memory/linked_ptr.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
16 #include "base/observer_list.h" 17 #include "base/observer_list.h"
17 #include "base/time.h" 18 #include "base/time.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 272
272 // Used to update |connection_code_|, see below. 273 // Used to update |connection_code_|, see below.
273 void UpdateServerConnectionManagerStatus( 274 void UpdateServerConnectionManagerStatus(
274 HttpResponse::ServerConnectionCode code); 275 HttpResponse::ServerConnectionCode code);
275 276
276 // Called once the first time thread_ is started to broadcast an initial 277 // Called once the first time thread_ is started to broadcast an initial
277 // session snapshot containing data like initial_sync_ended. Important when 278 // session snapshot containing data like initial_sync_ended. Important when
278 // the client starts up and does not need to perform an initial sync. 279 // the client starts up and does not need to perform an initial sync.
279 void SendInitialSnapshot(); 280 void SendInitialSnapshot();
280 281
282 // This is used for histogramming and analysis of ScheduleNudge* APIs.
283 // SyncScheduler is the ultimate choke-point for all such invocations (with
284 // and without InvalidationState variants, all NudgeSources, etc) and as such
285 // is the most flexible place to do this bookkeeping.
286 void UpdateNudgeTimeRecords(const sessions::SyncSourceInfo& info);
287
281 virtual void OnActionableError(const sessions::SyncSessionSnapshot& snapshot); 288 virtual void OnActionableError(const sessions::SyncSessionSnapshot& snapshot);
282 289
283 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_; 290 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_;
284 291
285 // A second factory specially for weak_handle_this_, to allow the handle 292 // A second factory specially for weak_handle_this_, to allow the handle
286 // to be const and alleviate threading concerns. 293 // to be const and alleviate threading concerns.
287 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_; 294 base::WeakPtrFactory<SyncSchedulerImpl> weak_ptr_factory_for_weak_handle_;
288 295
289 // For certain methods that need to worry about X-thread posting. 296 // For certain methods that need to worry about X-thread posting.
290 const WeakHandle<SyncSchedulerImpl> weak_handle_this_; 297 const WeakHandle<SyncSchedulerImpl> weak_handle_this_;
(...skipping 15 matching lines...) Expand all
306 313
307 // Server-tweakable sessions commit delay. 314 // Server-tweakable sessions commit delay.
308 base::TimeDelta sessions_commit_delay_; 315 base::TimeDelta sessions_commit_delay_;
309 316
310 // Periodic timer for polling. See AdjustPolling. 317 // Periodic timer for polling. See AdjustPolling.
311 base::RepeatingTimer<SyncSchedulerImpl> poll_timer_; 318 base::RepeatingTimer<SyncSchedulerImpl> poll_timer_;
312 319
313 // The mode of operation. 320 // The mode of operation.
314 Mode mode_; 321 Mode mode_;
315 322
316 // TODO(tim): Bug 26339. This needs to track more than just time I think,
317 // since the nudges could be for different types. Current impl doesn't care.
318 base::TimeTicks last_sync_session_end_time_;
319
320 // The latest connection code we got while trying to connect. 323 // The latest connection code we got while trying to connect.
321 HttpResponse::ServerConnectionCode connection_code_; 324 HttpResponse::ServerConnectionCode connection_code_;
322 325
323 // Tracks in-flight nudges so we can coalesce. 326 // Tracks in-flight nudges so we can coalesce.
324 scoped_ptr<SyncSessionJob> pending_nudge_; 327 scoped_ptr<SyncSessionJob> pending_nudge_;
325 328
326 // Current wait state. Null if we're not in backoff and not throttled. 329 // Current wait state. Null if we're not in backoff and not throttled.
327 scoped_ptr<WaitInterval> wait_interval_; 330 scoped_ptr<WaitInterval> wait_interval_;
328 331
329 scoped_ptr<BackoffDelayProvider> delay_provider_; 332 scoped_ptr<BackoffDelayProvider> delay_provider_;
330 333
331 // Invoked to run through the sync cycle. 334 // Invoked to run through the sync cycle.
332 scoped_ptr<Syncer> syncer_; 335 scoped_ptr<Syncer> syncer_;
333 336
334 sessions::SyncSessionContext *session_context_; 337 sessions::SyncSessionContext* session_context_;
338
339 // A map tracking LOCAL NudgeSource invocations of ScheduleNudge* APIs,
340 // organized by datatype. Each datatype that was part of the types requested
341 // in the call will have its TimeTicks value updated.
342 typedef std::map<ModelType, base::TimeTicks> ModelTypeTimeMap;
343 ModelTypeTimeMap last_local_nudges_by_model_type_;
344
345 // Used as an "anti-reentrancy defensive assertion".
346 // While true, it is illegal for any new scheduling activity to take place.
347 // Ensures that higher layers don't break this law in response to events that
348 // take place during a sync cycle. We call this out because such violations
349 // could result in tight sync loops hitting sync servers.
350 bool no_scheduling_allowed_;
335 351
336 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl); 352 DISALLOW_COPY_AND_ASSIGN(SyncSchedulerImpl);
337 }; 353 };
338 354
339 } // namespace syncer 355 } // namespace syncer
340 356
341 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_ 357 #endif // SYNC_ENGINE_SYNC_SCHEDULER_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | sync/engine/sync_scheduler_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698