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

Side by Side Diff: ios/chrome/browser/sync/sync_setup_service.cc

Issue 2376123003: [Sync] Move //components/sync to the syncer namespace. (Closed)
Patch Set: Rebase. Created 4 years, 2 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include "ios/chrome/browser/sync/sync_setup_service.h" 5 #include "ios/chrome/browser/sync/sync_setup_service.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
11 #include "components/prefs/pref_service.h" 11 #include "components/prefs/pref_service.h"
12 #include "components/sync/base/stop_source.h" 12 #include "components/sync/base/stop_source.h"
13 #include "components/sync/driver/sync_prefs.h" 13 #include "components/sync/driver/sync_prefs.h"
14 #include "components/sync/driver/sync_service.h" 14 #include "components/sync/driver/sync_service.h"
15 #include "components/sync/protocol/sync_protocol_error.h" 15 #include "components/sync/protocol/sync_protocol_error.h"
16 #include "google_apis/gaia/google_service_auth_error.h" 16 #include "google_apis/gaia/google_service_auth_error.h"
17 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 17 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
18 #include "ios/chrome/browser/pref_names.h" 18 #include "ios/chrome/browser/pref_names.h"
19 #include "net/base/network_change_notifier.h" 19 #include "net/base/network_change_notifier.h"
20 20
21 namespace { 21 namespace {
22 // The set of user-selectable datatypes. This must be in the same order as 22 // The set of user-selectable datatypes. This must be in the same order as
23 // |SyncSetupService::SyncableDatatype|. 23 // |SyncSetupService::SyncableDatatype|.
24 syncer::ModelType kDataTypes[] = { 24 syncer::ModelType kDataTypes[] = {
25 syncer::BOOKMARKS, syncer::TYPED_URLS, syncer::PASSWORDS, 25 syncer::BOOKMARKS, syncer::TYPED_URLS, syncer::PASSWORDS,
26 syncer::PROXY_TABS, syncer::AUTOFILL, syncer::PREFERENCES, 26 syncer::PROXY_TABS, syncer::AUTOFILL, syncer::PREFERENCES,
27 }; 27 };
28 } // namespace 28 } // namespace
29 29
30 SyncSetupService::SyncSetupService(sync_driver::SyncService* sync_service, 30 SyncSetupService::SyncSetupService(syncer::SyncService* sync_service,
31 PrefService* prefs) 31 PrefService* prefs)
32 : sync_service_(sync_service), prefs_(prefs) { 32 : sync_service_(sync_service), prefs_(prefs) {
33 DCHECK(sync_service_); 33 DCHECK(sync_service_);
34 DCHECK(prefs_); 34 DCHECK(prefs_);
35 for (unsigned int i = 0; i < arraysize(kDataTypes); ++i) { 35 for (unsigned int i = 0; i < arraysize(kDataTypes); ++i) {
36 user_selectable_types_.Put(kDataTypes[i]); 36 user_selectable_types_.Put(kDataTypes[i]);
37 } 37 }
38 } 38 }
39 39
40 SyncSetupService::~SyncSetupService() { 40 SyncSetupService::~SyncSetupService() {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 case SyncSetupService::kSyncServiceNeedsPassphrase: 85 case SyncSetupService::kSyncServiceNeedsPassphrase:
86 case SyncSetupService::kSyncServiceUnrecoverableError: 86 case SyncSetupService::kSyncServiceUnrecoverableError:
87 return true; 87 return true;
88 default: 88 default:
89 NOTREACHED() << "Unknown sync service state."; 89 NOTREACHED() << "Unknown sync service state.";
90 return true; 90 return true;
91 } 91 }
92 } 92 }
93 93
94 bool SyncSetupService::IsSyncingAllDataTypes() const { 94 bool SyncSetupService::IsSyncingAllDataTypes() const {
95 sync_driver::SyncPrefs sync_prefs(prefs_); 95 syncer::SyncPrefs sync_prefs(prefs_);
96 return sync_prefs.HasKeepEverythingSynced(); 96 return sync_prefs.HasKeepEverythingSynced();
97 } 97 }
98 98
99 void SyncSetupService::SetSyncingAllDataTypes(bool sync_all) { 99 void SyncSetupService::SetSyncingAllDataTypes(bool sync_all) {
100 sync_blocker_ = sync_service_->GetSetupInProgressHandle(); 100 sync_blocker_ = sync_service_->GetSetupInProgressHandle();
101 if (sync_all && !IsSyncEnabled()) 101 if (sync_all && !IsSyncEnabled())
102 SetSyncEnabled(true); 102 SetSyncEnabled(true);
103 sync_service_->OnUserChoseDatatypes( 103 sync_service_->OnUserChoseDatatypes(
104 sync_all, Intersection(GetDataTypes(), syncer::UserSelectableTypes())); 104 sync_all, Intersection(GetDataTypes(), syncer::UserSelectableTypes()));
105 } 105 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 188 }
189 189
190 void SyncSetupService::SetSyncEnabledWithoutChangingDatatypes( 190 void SyncSetupService::SetSyncEnabledWithoutChangingDatatypes(
191 bool sync_enabled) { 191 bool sync_enabled) {
192 sync_blocker_ = sync_service_->GetSetupInProgressHandle(); 192 sync_blocker_ = sync_service_->GetSetupInProgressHandle();
193 if (sync_enabled) { 193 if (sync_enabled) {
194 sync_service_->RequestStart(); 194 sync_service_->RequestStart();
195 } else { 195 } else {
196 UMA_HISTOGRAM_ENUMERATION("Sync.StopSource", syncer::CHROME_SYNC_SETTINGS, 196 UMA_HISTOGRAM_ENUMERATION("Sync.StopSource", syncer::CHROME_SYNC_SETTINGS,
197 syncer::STOP_SOURCE_LIMIT); 197 syncer::STOP_SOURCE_LIMIT);
198 sync_service_->RequestStop(sync_driver::SyncService::KEEP_DATA); 198 sync_service_->RequestStop(syncer::SyncService::KEEP_DATA);
199 } 199 }
200 } 200 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/sync/sync_setup_service.h ('k') | ios/chrome/browser/sync/sync_setup_service_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698