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

Side by Side Diff: components/sync/driver/sync_service_base.cc

Issue 2732333003: [Sync] ModelTypeStore factory shouldn't require valid PSS to function correctly (Closed)
Patch Set: Address comments Created 3 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
« no previous file with comments | « components/sync/driver/sync_service_base.h ('k') | components/sync/model/model_type_store.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/sync/driver/sync_service_base.h" 5 #include "components/sync/driver/sync_service_base.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/path_service.h" 14 #include "base/path_service.h"
15 #include "base/syslog_logging.h" 15 #include "base/syslog_logging.h"
16 #include "components/invalidation/public/invalidation_service.h" 16 #include "components/invalidation/public/invalidation_service.h"
17 #include "components/sync/base/report_unrecoverable_error.h" 17 #include "components/sync/base/report_unrecoverable_error.h"
18 #include "components/sync/device_info/local_device_info_provider.h" 18 #include "components/sync/device_info/local_device_info_provider.h"
19 #include "components/sync/driver/sync_driver_switches.h" 19 #include "components/sync/driver/sync_driver_switches.h"
20 #include "components/sync/engine/engine_components_factory_impl.h" 20 #include "components/sync/engine/engine_components_factory_impl.h"
21 21
22 namespace syncer { 22 namespace syncer {
23 23
24 namespace { 24 namespace {
25 25
26 const base::FilePath::CharType kSyncDataFolderName[] = 26 const base::FilePath::CharType kSyncDataFolderName[] =
27 FILE_PATH_LITERAL("Sync Data"); 27 FILE_PATH_LITERAL("Sync Data");
28 28
29 const base::FilePath::CharType kLevelDBFolderName[] =
30 FILE_PATH_LITERAL("LevelDB");
31
29 EngineComponentsFactory::Switches EngineSwitchesFromCommandLine() { 32 EngineComponentsFactory::Switches EngineSwitchesFromCommandLine() {
30 EngineComponentsFactory::Switches factory_switches = { 33 EngineComponentsFactory::Switches factory_switches = {
31 EngineComponentsFactory::ENCRYPTION_KEYSTORE, 34 EngineComponentsFactory::ENCRYPTION_KEYSTORE,
32 EngineComponentsFactory::BACKOFF_NORMAL}; 35 EngineComponentsFactory::BACKOFF_NORMAL};
33 36
34 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); 37 base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
35 if (cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) { 38 if (cl->HasSwitch(switches::kSyncShortInitialRetryOverride)) {
36 factory_switches.backoff_override = 39 factory_switches.backoff_override =
37 EngineComponentsFactory::BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE; 40 EngineComponentsFactory::BACKOFF_SHORT_INITIAL_RETRY_OVERRIDE;
38 } 41 }
(...skipping 12 matching lines...) Expand all
51 54
52 SyncServiceBase::SyncServiceBase(std::unique_ptr<SyncClient> sync_client, 55 SyncServiceBase::SyncServiceBase(std::unique_ptr<SyncClient> sync_client,
53 std::unique_ptr<SigninManagerWrapper> signin, 56 std::unique_ptr<SigninManagerWrapper> signin,
54 const version_info::Channel& channel, 57 const version_info::Channel& channel,
55 const base::FilePath& base_directory, 58 const base::FilePath& base_directory,
56 const std::string& debug_identifier) 59 const std::string& debug_identifier)
57 : sync_client_(std::move(sync_client)), 60 : sync_client_(std::move(sync_client)),
58 signin_(std::move(signin)), 61 signin_(std::move(signin)),
59 channel_(channel), 62 channel_(channel),
60 base_directory_(base_directory), 63 base_directory_(base_directory),
61 sync_data_folder_(
62 base_directory_.Append(base::FilePath(kSyncDataFolderName))),
63 debug_identifier_(debug_identifier), 64 debug_identifier_(debug_identifier),
64 sync_prefs_(sync_client_->GetPrefService()) { 65 sync_prefs_(sync_client_->GetPrefService()) {
65 ResetCryptoState(); 66 ResetCryptoState();
66 } 67 }
67 68
68 SyncServiceBase::~SyncServiceBase() = default; 69 SyncServiceBase::~SyncServiceBase() = default;
69 70
70 void SyncServiceBase::AddObserver(SyncServiceObserver* observer) { 71 void SyncServiceBase::AddObserver(SyncServiceObserver* observer) {
71 DCHECK(thread_checker_.CalledOnValidThread()); 72 DCHECK(thread_checker_.CalledOnValidThread());
72 observers_.AddObserver(observer); 73 observers_.AddObserver(observer);
73 } 74 }
74 75
75 void SyncServiceBase::RemoveObserver(SyncServiceObserver* observer) { 76 void SyncServiceBase::RemoveObserver(SyncServiceObserver* observer) {
76 DCHECK(thread_checker_.CalledOnValidThread()); 77 DCHECK(thread_checker_.CalledOnValidThread());
77 observers_.RemoveObserver(observer); 78 observers_.RemoveObserver(observer);
78 } 79 }
79 80
81 // static
82 base::FilePath SyncServiceBase::FormatSyncDataPath(
83 const base::FilePath& base_directory) {
84 return base_directory.Append(base::FilePath(kSyncDataFolderName));
85 }
86
87 // static
88 base::FilePath SyncServiceBase::FormatSharedModelTypeStorePath(
89 const base::FilePath& base_directory) {
90 return FormatSyncDataPath(base_directory)
91 .Append(base::FilePath(kLevelDBFolderName));
92 }
93
80 bool SyncServiceBase::HasObserver(const SyncServiceObserver* observer) const { 94 bool SyncServiceBase::HasObserver(const SyncServiceObserver* observer) const {
81 DCHECK(thread_checker_.CalledOnValidThread()); 95 DCHECK(thread_checker_.CalledOnValidThread());
82 return observers_.HasObserver(observer); 96 return observers_.HasObserver(observer);
83 } 97 }
84 98
85 void SyncServiceBase::NotifyObservers() { 99 void SyncServiceBase::NotifyObservers() {
86 for (auto& observer : observers_) { 100 for (auto& observer : observers_) {
87 observer.OnStateChanged(this); 101 observer.OnStateChanged(this);
88 } 102 }
89 } 103 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 void SyncServiceBase::ResetCryptoState() { 154 void SyncServiceBase::ResetCryptoState() {
141 crypto_ = base::MakeUnique<SyncServiceCrypto>( 155 crypto_ = base::MakeUnique<SyncServiceCrypto>(
142 base::BindRepeating(&SyncServiceBase::NotifyObservers, 156 base::BindRepeating(&SyncServiceBase::NotifyObservers,
143 base::Unretained(this)), 157 base::Unretained(this)),
144 base::BindRepeating(&SyncService::GetPreferredDataTypes, 158 base::BindRepeating(&SyncService::GetPreferredDataTypes,
145 base::Unretained(this)), 159 base::Unretained(this)),
146 &sync_prefs_); 160 &sync_prefs_);
147 } 161 }
148 162
149 } // namespace syncer 163 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/driver/sync_service_base.h ('k') | components/sync/model/model_type_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698