 Chromium Code Reviews
 Chromium Code Reviews Issue 1858673002:
  [Sync] Inject startup dependencies into StartupController.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1858673002:
  [Sync] Inject startup dependencies into StartupController.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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" | 
| 11 #include "sync/internal_api/public/base/model_type.h" | 11 #include "sync/internal_api/public/base/model_type.h" | 
| 12 | 12 | 
| 13 class ProfileOAuth2TokenService; | |
| 14 class SigninManagerWrapper; | |
| 15 | |
| 16 namespace sync_driver { | 13 namespace sync_driver { | 
| 17 class SyncPrefs; | 14 class SyncPrefs; | 
| 18 } | 15 } | 
| 19 | 16 | 
| 20 namespace browser_sync { | 17 namespace browser_sync { | 
| 21 | 18 | 
| 22 // This class is used by ProfileSyncService to manage all logic and state | 19 // This class is used by ProfileSyncService to manage all logic and state | 
| 23 // pertaining to initialization of the SyncBackendHost (colloquially referred | 20 // pertaining to initialization of the SyncBackendHost (colloquially referred | 
| 24 // to as "the backend"). | 21 // to as "the backend"). | 
| 25 class StartupController { | 22 class StartupController { | 
| 26 public: | 23 public: | 
| 27 StartupController(const ProfileOAuth2TokenService* token_service, | 24 StartupController(const sync_driver::SyncPrefs* sync_prefs, | 
| 28 const sync_driver::SyncPrefs* sync_prefs, | 25 base::Callback<bool()> can_start, | 
| 29 const SigninManagerWrapper* signin, | |
| 30 base::Closure start_backend); | 26 base::Closure start_backend); | 
| 31 ~StartupController(); | 27 ~StartupController(); | 
| 32 | 28 | 
| 33 // 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. | 
| 34 // Returns true if these preconditions are met, although does not imply | 30 // Returns true if these preconditions are met, although does not imply | 
| 35 // the backend was started. | 31 // the backend was started. | 
| 36 bool TryStart(); | 32 bool TryStart(); | 
| 37 | 33 | 
| 38 // Called when a datatype (SyncableService) has a need for sync to start | 34 // Called when a datatype (SyncableService) has a need for sync to start | 
| 39 // ASAP, presumably because a local change event has occurred but we're | 35 // ASAP, presumably because a local change event has occurred but we're | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 | 78 | 
| 83 // If |true|, there is setup UI visible so we should not start downloading | 79 // If |true|, there is setup UI visible so we should not start downloading | 
| 84 // data types. | 80 // data types. | 
| 85 // Note: this is explicitly controlled by higher layers (UI) and is meant to | 81 // Note: this is explicitly controlled by higher layers (UI) and is meant to | 
| 86 // reflect what the UI claims the setup state to be. Therefore, only set this | 82 // reflect what the UI claims the setup state to be. Therefore, only set this | 
| 87 // due to explicit requests to do so via SetSetupInProgress. | 83 // due to explicit requests to do so via SetSetupInProgress. | 
| 88 bool setup_in_progress_; | 84 bool setup_in_progress_; | 
| 89 | 85 | 
| 90 const sync_driver::SyncPrefs* sync_prefs_; | 86 const sync_driver::SyncPrefs* sync_prefs_; | 
| 91 | 87 | 
| 92 const ProfileOAuth2TokenService* token_service_; | 88 base::Callback<bool()> can_start_; | 
| 
Nicolas Zea
2016/04/04 20:44:17
comment what this is for
 
maxbogue
2016/04/04 22:56:55
Done.
 | |
| 93 | |
| 94 const SigninManagerWrapper* signin_; | |
| 95 | 89 | 
| 96 // The callback we invoke when it's time to call expensive | 90 // The callback we invoke when it's time to call expensive | 
| 97 // startup routines for the sync backend. | 91 // startup routines for the sync backend. | 
| 98 base::Closure start_backend_; | 92 base::Closure start_backend_; | 
| 99 | 93 | 
| 100 // The time at which we invoked the start_backend_ callback. | 94 // The time at which we invoked the start_backend_ callback. | 
| 101 base::Time start_backend_time_; | 95 base::Time start_backend_time_; | 
| 102 | 96 | 
| 103 base::TimeDelta fallback_timeout_; | 97 base::TimeDelta fallback_timeout_; | 
| 104 | 98 | 
| 105 // Used to compute preferred_types from SyncPrefs as-needed. | 99 // Used to compute preferred_types from SyncPrefs as-needed. | 
| 106 syncer::ModelTypeSet registered_types_; | 100 syncer::ModelTypeSet registered_types_; | 
| 107 | 101 | 
| 108 base::WeakPtrFactory<StartupController> weak_factory_; | 102 base::WeakPtrFactory<StartupController> weak_factory_; | 
| 109 }; | 103 }; | 
| 110 | 104 | 
| 111 } // namespace browser_sync | 105 } // namespace browser_sync | 
| 112 | 106 | 
| 113 #endif // COMPONENTS_SYNC_DRIVER_STARTUP_CONTROLLER_H_ | 107 #endif // COMPONENTS_SYNC_DRIVER_STARTUP_CONTROLLER_H_ | 
| OLD | NEW |