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

Side by Side Diff: chrome/browser/sync/startup_controller.cc

Issue 195873020: [Sync] Move SyncPrefs into sync_driver component (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rerererebase Created 6 years, 9 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
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 #include "chrome/browser/sync/startup_controller.h" 5 #include "chrome/browser/sync/startup_controller.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "chrome/browser/managed_mode/managed_user_signin_manager_wrapper.h" 11 #include "chrome/browser/managed_mode/managed_user_signin_manager_wrapper.h"
12 #include "chrome/browser/sync/sync_prefs.h"
13 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
14 #include "components/signin/core/profile_oauth2_token_service.h" 13 #include "components/signin/core/profile_oauth2_token_service.h"
14 #include "components/sync_driver/sync_prefs.h"
15 15
16 namespace browser_sync { 16 namespace browser_sync {
17 17
18 namespace { 18 namespace {
19 19
20 // The amount of time we'll wait to initialize sync if no data type triggers 20 // The amount of time we'll wait to initialize sync if no data type triggers
21 // initialization via a StartSyncFlare. 21 // initialization via a StartSyncFlare.
22 const int kDeferredInitFallbackSeconds = 10; 22 const int kDeferredInitFallbackSeconds = 10;
23 23
24 // Enum (for UMA, primarily) defining different events that cause us to 24 // Enum (for UMA, primarily) defining different events that cause us to
25 // exit the "deferred" state of initialization and invoke start_backend. 25 // exit the "deferred" state of initialization and invoke start_backend.
26 enum DeferredInitTrigger { 26 enum DeferredInitTrigger {
27 // We have received a signal from a SyncableService requesting that sync 27 // We have received a signal from a SyncableService requesting that sync
28 // starts as soon as possible. 28 // starts as soon as possible.
29 TRIGGER_DATA_TYPE_REQUEST, 29 TRIGGER_DATA_TYPE_REQUEST,
30 // No data type requested sync to start and our fallback timer expired. 30 // No data type requested sync to start and our fallback timer expired.
31 TRIGGER_FALLBACK_TIMER, 31 TRIGGER_FALLBACK_TIMER,
32 MAX_TRIGGER_VALUE 32 MAX_TRIGGER_VALUE
33 }; 33 };
34 34
35 } // namespace 35 } // namespace
36 36
37 StartupController::StartupController( 37 StartupController::StartupController(
38 ProfileSyncServiceStartBehavior start_behavior, 38 ProfileSyncServiceStartBehavior start_behavior,
39 const ProfileOAuth2TokenService* token_service, 39 const ProfileOAuth2TokenService* token_service,
40 const browser_sync::SyncPrefs* sync_prefs, 40 const sync_driver::SyncPrefs* sync_prefs,
41 const ManagedUserSigninManagerWrapper* signin, 41 const ManagedUserSigninManagerWrapper* signin,
42 base::Closure start_backend) 42 base::Closure start_backend)
43 : received_start_request_(false), 43 : received_start_request_(false),
44 setup_in_progress_(false), 44 setup_in_progress_(false),
45 auto_start_enabled_(start_behavior == AUTO_START), 45 auto_start_enabled_(start_behavior == AUTO_START),
46 sync_prefs_(sync_prefs), 46 sync_prefs_(sync_prefs),
47 token_service_(token_service), 47 token_service_(token_service),
48 signin_(signin), 48 signin_(signin),
49 start_backend_(start_backend), 49 start_backend_(start_backend),
50 fallback_timeout_(base::TimeDelta::FromSeconds( 50 fallback_timeout_(
51 kDeferredInitFallbackSeconds)), 51 base::TimeDelta::FromSeconds(kDeferredInitFallbackSeconds)),
52 weak_factory_(this) { 52 weak_factory_(this) {
53 53
54 if (CommandLine::ForCurrentProcess()->HasSwitch( 54 if (CommandLine::ForCurrentProcess()->HasSwitch(
55 switches::kSyncDeferredStartupTimeoutSeconds)) { 55 switches::kSyncDeferredStartupTimeoutSeconds)) {
56 int timeout = kDeferredInitFallbackSeconds; 56 int timeout = kDeferredInitFallbackSeconds;
57 if (base::StringToInt(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 57 if (base::StringToInt(CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
58 switches::kSyncDeferredStartupTimeoutSeconds), &timeout)) { 58 switches::kSyncDeferredStartupTimeoutSeconds), &timeout)) {
59 DCHECK_GE(0, timeout); 59 DCHECK_GE(0, timeout);
60 DVLOG(2) << "Sync StartupController overriding startup timeout to " 60 DVLOG(2) << "Sync StartupController overriding startup timeout to "
61 << timeout << " seconds."; 61 << timeout << " seconds.";
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 syncer::MODEL_TYPE_COUNT); 223 syncer::MODEL_TYPE_COUNT);
224 UMA_HISTOGRAM_ENUMERATION("Sync.Startup.DeferredInitTrigger", 224 UMA_HISTOGRAM_ENUMERATION("Sync.Startup.DeferredInitTrigger",
225 TRIGGER_DATA_TYPE_REQUEST, 225 TRIGGER_DATA_TYPE_REQUEST,
226 MAX_TRIGGER_VALUE); 226 MAX_TRIGGER_VALUE);
227 } 227 }
228 received_start_request_ = true; 228 received_start_request_ = true;
229 TryStart(); 229 TryStart();
230 } 230 }
231 231
232 } // namespace browser_sync 232 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/startup_controller.h ('k') | chrome/browser/sync/startup_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698