Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 11 matching lines...) Expand all Loading... | |
| 22 class StartupController { | 22 class StartupController { |
| 23 public: | 23 public: |
| 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 // |request_immediate| will force immediate startup if true, rather than |
| 33 // deferred, once preconditions are met. | |
| 34 bool TryStart(bool request_immediate); | |
|
maxbogue
2016/07/15 21:44:48
I think the code will be much more readable if you
Nicolas Zea
2016/07/15 22:42:22
Good call, done.
| |
| 33 | 35 |
| 34 // Called when a datatype (SyncableService) has a need for sync to start | 36 // 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 | 37 // ASAP, presumably because a local change event has occurred but we're |
| 36 // still in deferred start mode, meaning the SyncableService hasn't been | 38 // still in deferred start mode, meaning the SyncableService hasn't been |
| 37 // told to MergeDataAndStartSyncing yet. | 39 // told to MergeDataAndStartSyncing yet. |
| 38 // It is expected that |type| is a currently active datatype. | 40 // It is expected that |type| is a currently active datatype. |
| 39 void OnDataTypeRequestsSyncStartup(syncer::ModelType type); | 41 void OnDataTypeRequestsSyncStartup(syncer::ModelType type); |
| 40 | 42 |
| 41 // Prepares this object for a new attempt to start sync, forgetting | 43 // Prepares this object for a new attempt to start sync, forgetting |
| 42 // whether or not preconditions were previously met. | 44 // whether or not preconditions were previously met. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 | 102 |
| 101 // Used to compute preferred_types from SyncPrefs as-needed. | 103 // Used to compute preferred_types from SyncPrefs as-needed. |
| 102 syncer::ModelTypeSet registered_types_; | 104 syncer::ModelTypeSet registered_types_; |
| 103 | 105 |
| 104 base::WeakPtrFactory<StartupController> weak_factory_; | 106 base::WeakPtrFactory<StartupController> weak_factory_; |
| 105 }; | 107 }; |
| 106 | 108 |
| 107 } // namespace browser_sync | 109 } // namespace browser_sync |
| 108 | 110 |
| 109 #endif // COMPONENTS_SYNC_DRIVER_STARTUP_CONTROLLER_H_ | 111 #endif // COMPONENTS_SYNC_DRIVER_STARTUP_CONTROLLER_H_ |
| OLD | NEW |