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

Side by Side Diff: components/sync_driver/startup_controller.h

Issue 2159453002: [Sync] Don't start up sync when FirstSetupCompleted is false and no setup in progress (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Android fix attempt Created 4 years, 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_SYNC_DRIVER_STARTUP_CONTROLLER_H_ 5 #ifndef COMPONENTS_SYNC_DRIVER_STARTUP_CONTROLLER_H_
6 #define COMPONENTS_SYNC_DRIVER_STARTUP_CONTROLLER_H_ 6 #define COMPONENTS_SYNC_DRIVER_STARTUP_CONTROLLER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 13 matching lines...) Expand all
24 StartupController(const sync_driver::SyncPrefs* sync_prefs, 24 StartupController(const sync_driver::SyncPrefs* sync_prefs,
25 base::Callback<bool()> can_start, 25 base::Callback<bool()> can_start,
26 base::Closure start_backend); 26 base::Closure start_backend);
27 ~StartupController(); 27 ~StartupController();
28 28
29 // Starts up sync if it is requested by the user and preconditions are met. 29 // Starts up sync if it is requested by the user and preconditions are met.
30 // Returns true if these preconditions are met, although does not imply 30 // Returns true if these preconditions are met, although does not imply
31 // the backend was started. 31 // the backend was started.
32 bool TryStart(); 32 bool TryStart();
33 33
34 // Same as TryStart() above, but bypasses deferred startup and the first setup
35 // complete check.
36 bool TryStartImmediately();
37
34 // Called when a datatype (SyncableService) has a need for sync to start 38 // Called when a datatype (SyncableService) has a need for sync to start
35 // ASAP, presumably because a local change event has occurred but we're 39 // ASAP, presumably because a local change event has occurred but we're
36 // still in deferred start mode, meaning the SyncableService hasn't been 40 // still in deferred start mode, meaning the SyncableService hasn't been
37 // told to MergeDataAndStartSyncing yet. 41 // told to MergeDataAndStartSyncing yet.
38 // It is expected that |type| is a currently active datatype. 42 // It is expected that |type| is a currently active datatype.
39 void OnDataTypeRequestsSyncStartup(syncer::ModelType type); 43 void OnDataTypeRequestsSyncStartup(syncer::ModelType type);
40 44
41 // Prepares this object for a new attempt to start sync, forgetting 45 // Prepares this object for a new attempt to start sync, forgetting
42 // whether or not preconditions were previously met. 46 // whether or not preconditions were previously met.
43 // NOTE: This resets internal state managed by this class, but does not 47 // NOTE: This resets internal state managed by this class, but does not
(...skipping 16 matching lines...) Expand all
60 STARTUP_BACKEND_DEFERRED, 64 STARTUP_BACKEND_DEFERRED,
61 STARTUP_IMMEDIATE 65 STARTUP_IMMEDIATE
62 }; 66 };
63 // Returns true if all conditions to start the backend are met. 67 // Returns true if all conditions to start the backend are met.
64 bool StartUp(StartUpDeferredOption deferred_option); 68 bool StartUp(StartUpDeferredOption deferred_option);
65 void OnFallbackStartupTimerExpired(); 69 void OnFallbackStartupTimerExpired();
66 70
67 // Records time spent in deferred state with UMA histograms. 71 // Records time spent in deferred state with UMA histograms.
68 void RecordTimeDeferred(); 72 void RecordTimeDeferred();
69 73
74 // If true, will bypass the FirstSetupComplete check when triggering sync
75 // startup.
76 bool bypass_setup_complete_;
77
70 // True if we should start sync ASAP because either a SyncableService has 78 // True if we should start sync ASAP because either a SyncableService has
71 // requested it, or we're done waiting for a sign and decided to go ahead. 79 // requested it, or we're done waiting for a sign and decided to go ahead.
72 bool received_start_request_; 80 bool received_start_request_;
73 81
74 // The time that StartUp() is called. This is used to calculate time spent 82 // The time that StartUp() is called. This is used to calculate time spent
75 // in the deferred state; that is, after StartUp and before invoking the 83 // in the deferred state; that is, after StartUp and before invoking the
76 // start_backend_ callback. 84 // start_backend_ callback.
77 base::Time start_up_time_; 85 base::Time start_up_time_;
78 86
79 // If |true|, there is setup UI visible so we should not start downloading 87 // If |true|, there is setup UI visible so we should not start downloading
(...skipping 20 matching lines...) Expand all
100 108
101 // Used to compute preferred_types from SyncPrefs as-needed. 109 // Used to compute preferred_types from SyncPrefs as-needed.
102 syncer::ModelTypeSet registered_types_; 110 syncer::ModelTypeSet registered_types_;
103 111
104 base::WeakPtrFactory<StartupController> weak_factory_; 112 base::WeakPtrFactory<StartupController> weak_factory_;
105 }; 113 };
106 114
107 } // namespace browser_sync 115 } // namespace browser_sync
108 116
109 #endif // COMPONENTS_SYNC_DRIVER_STARTUP_CONTROLLER_H_ 117 #endif // COMPONENTS_SYNC_DRIVER_STARTUP_CONTROLLER_H_
OLDNEW
« no previous file with comments | « components/browser_sync/browser/profile_sync_service_unittest.cc ('k') | components/sync_driver/startup_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698