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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host.cc

Issue 9512005: [Sync] Move BridgedSyncNotifier and ChromeSyncNotificationBridge to glue/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to head Created 8 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
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host.h ('k') | chrome/browser/sync/notifier/DEPS » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "chrome/browser/sync/glue/sync_backend_host.h" 7 #include "chrome/browser/sync/glue/sync_backend_host.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/file_path.h" 15 #include "base/file_path.h"
16 #include "base/file_util.h" 16 #include "base/file_util.h"
17 #include "base/location.h" 17 #include "base/location.h"
18 #include "base/threading/thread_restrictions.h" 18 #include "base/threading/thread_restrictions.h"
19 #include "base/timer.h" 19 #include "base/timer.h"
20 #include "base/utf_string_conversions.h" 20 #include "base/utf_string_conversions.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/signin/token_service.h" 22 #include "chrome/browser/signin/token_service.h"
23 #include "chrome/browser/sync/glue/bridged_sync_notifier.h"
23 #include "chrome/browser/sync/glue/change_processor.h" 24 #include "chrome/browser/sync/glue/change_processor.h"
24 #include "chrome/browser/sync/glue/chrome_encryptor.h" 25 #include "chrome/browser/sync/glue/chrome_encryptor.h"
25 #include "chrome/browser/sync/glue/http_bridge.h" 26 #include "chrome/browser/sync/glue/http_bridge.h"
26 #include "chrome/browser/sync/glue/sync_backend_registrar.h" 27 #include "chrome/browser/sync/glue/sync_backend_registrar.h"
27 #include "chrome/browser/sync/internal_api/base_transaction.h" 28 #include "chrome/browser/sync/internal_api/base_transaction.h"
28 #include "chrome/browser/sync/internal_api/read_transaction.h" 29 #include "chrome/browser/sync/internal_api/read_transaction.h"
29 #include "chrome/browser/sync/notifier/sync_notifier.h" 30 #include "chrome/browser/sync/notifier/sync_notifier.h"
30 #include "chrome/browser/sync/protocol/encryption.pb.h" 31 #include "chrome/browser/sync/protocol/encryption.pb.h"
31 #include "chrome/browser/sync/protocol/sync.pb.h" 32 #include "chrome/browser/sync/protocol/sync.pb.h"
32 #include "chrome/browser/sync/sessions/session_state.h" 33 #include "chrome/browser/sync/sessions/session_state.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 const base::WeakPtr<SyncPrefs>& sync_prefs) 228 const base::WeakPtr<SyncPrefs>& sync_prefs)
228 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 229 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
229 sync_thread_("Chrome_SyncThread"), 230 sync_thread_("Chrome_SyncThread"),
230 frontend_loop_(MessageLoop::current()), 231 frontend_loop_(MessageLoop::current()),
231 profile_(profile), 232 profile_(profile),
232 name_(name), 233 name_(name),
233 core_(new Core(name, profile_->GetPath().Append(kSyncDataFolderName), 234 core_(new Core(name, profile_->GetPath().Append(kSyncDataFolderName),
234 weak_ptr_factory_.GetWeakPtr())), 235 weak_ptr_factory_.GetWeakPtr())),
235 initialization_state_(NOT_ATTEMPTED), 236 initialization_state_(NOT_ATTEMPTED),
236 sync_prefs_(sync_prefs), 237 sync_prefs_(sync_prefs),
238 chrome_sync_notification_bridge_(profile_),
237 sync_notifier_factory_( 239 sync_notifier_factory_(
238 profile_,
239 content::GetUserAgent(GURL()), 240 content::GetUserAgent(GURL()),
240 profile_->GetRequestContext(), 241 profile_->GetRequestContext(),
241 sync_prefs, 242 sync_prefs,
242 *CommandLine::ForCurrentProcess()), 243 *CommandLine::ForCurrentProcess()),
243 frontend_(NULL), 244 frontend_(NULL),
244 last_auth_error_(AuthError::None()) { 245 last_auth_error_(AuthError::None()) {
245 } 246 }
246 247
247 SyncBackendHost::SyncBackendHost(Profile* profile) 248 SyncBackendHost::SyncBackendHost(Profile* profile)
248 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 249 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
249 sync_thread_("Chrome_SyncThread"), 250 sync_thread_("Chrome_SyncThread"),
250 frontend_loop_(MessageLoop::current()), 251 frontend_loop_(MessageLoop::current()),
251 profile_(profile), 252 profile_(profile),
252 name_("Unknown"), 253 name_("Unknown"),
253 initialization_state_(NOT_ATTEMPTED), 254 initialization_state_(NOT_ATTEMPTED),
255 chrome_sync_notification_bridge_(profile_),
254 sync_notifier_factory_( 256 sync_notifier_factory_(
255 profile_,
256 content::GetUserAgent(GURL()), 257 content::GetUserAgent(GURL()),
257 NULL, 258 NULL,
258 base::WeakPtr<sync_notifier::InvalidationVersionTracker>(), 259 base::WeakPtr<sync_notifier::InvalidationVersionTracker>(),
259 *CommandLine::ForCurrentProcess()), 260 *CommandLine::ForCurrentProcess()),
260 frontend_(NULL), 261 frontend_(NULL),
261 last_auth_error_(AuthError::None()) { 262 last_auth_error_(AuthError::None()) {
262 } 263 }
263 264
264 SyncBackendHost::~SyncBackendHost() { 265 SyncBackendHost::~SyncBackendHost() {
265 DCHECK(!core_ && !frontend_) << "Must call Shutdown before destructor."; 266 DCHECK(!core_ && !frontend_) << "Must call Shutdown before destructor.";
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 initialization_state_ = CREATING_SYNC_MANAGER; 304 initialization_state_ = CREATING_SYNC_MANAGER;
304 InitCore(DoInitializeOptions( 305 InitCore(DoInitializeOptions(
305 sync_thread_.message_loop(), 306 sync_thread_.message_loop(),
306 registrar_.get(), 307 registrar_.get(),
307 &extensions_activity_monitor_, 308 &extensions_activity_monitor_,
308 event_handler, 309 event_handler,
309 sync_service_url, 310 sync_service_url,
310 base::Bind(&MakeHttpBridgeFactory, 311 base::Bind(&MakeHttpBridgeFactory,
311 make_scoped_refptr(profile_->GetRequestContext())), 312 make_scoped_refptr(profile_->GetRequestContext())),
312 credentials, 313 credentials,
314 &chrome_sync_notification_bridge_,
313 &sync_notifier_factory_, 315 &sync_notifier_factory_,
314 delete_sync_data_folder, 316 delete_sync_data_folder,
315 sync_prefs_->GetEncryptionBootstrapToken(), 317 sync_prefs_->GetEncryptionBootstrapToken(),
316 false, 318 false,
317 unrecoverable_error_handler, 319 unrecoverable_error_handler,
318 report_unrecoverable_error_function)); 320 report_unrecoverable_error_function));
319 } 321 }
320 322
321 void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) { 323 void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) {
322 sync_thread_.message_loop()->PostTask(FROM_HERE, 324 sync_thread_.message_loop()->PostTask(FROM_HERE,
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 } 717 }
716 718
717 SyncBackendHost::DoInitializeOptions::DoInitializeOptions( 719 SyncBackendHost::DoInitializeOptions::DoInitializeOptions(
718 MessageLoop* sync_loop, 720 MessageLoop* sync_loop,
719 SyncBackendRegistrar* registrar, 721 SyncBackendRegistrar* registrar,
720 ExtensionsActivityMonitor* extensions_activity_monitor, 722 ExtensionsActivityMonitor* extensions_activity_monitor,
721 const WeakHandle<JsEventHandler>& event_handler, 723 const WeakHandle<JsEventHandler>& event_handler,
722 const GURL& service_url, 724 const GURL& service_url,
723 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn, 725 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn,
724 const sync_api::SyncCredentials& credentials, 726 const sync_api::SyncCredentials& credentials,
727 ChromeSyncNotificationBridge* chrome_sync_notification_bridge,
725 sync_notifier::SyncNotifierFactory* sync_notifier_factory, 728 sync_notifier::SyncNotifierFactory* sync_notifier_factory,
726 bool delete_sync_data_folder, 729 bool delete_sync_data_folder,
727 const std::string& restored_key_for_bootstrapping, 730 const std::string& restored_key_for_bootstrapping,
728 bool setup_for_test_mode, 731 bool setup_for_test_mode,
729 UnrecoverableErrorHandler* unrecoverable_error_handler, 732 UnrecoverableErrorHandler* unrecoverable_error_handler,
730 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) 733 ReportUnrecoverableErrorFunction report_unrecoverable_error_function)
731 : sync_loop(sync_loop), 734 : sync_loop(sync_loop),
732 registrar(registrar), 735 registrar(registrar),
733 extensions_activity_monitor(extensions_activity_monitor), 736 extensions_activity_monitor(extensions_activity_monitor),
734 event_handler(event_handler), 737 event_handler(event_handler),
735 service_url(service_url), 738 service_url(service_url),
736 make_http_bridge_factory_fn(make_http_bridge_factory_fn), 739 make_http_bridge_factory_fn(make_http_bridge_factory_fn),
737 credentials(credentials), 740 credentials(credentials),
741 chrome_sync_notification_bridge(chrome_sync_notification_bridge),
738 sync_notifier_factory(sync_notifier_factory), 742 sync_notifier_factory(sync_notifier_factory),
739 delete_sync_data_folder(delete_sync_data_folder), 743 delete_sync_data_folder(delete_sync_data_folder),
740 restored_key_for_bootstrapping(restored_key_for_bootstrapping), 744 restored_key_for_bootstrapping(restored_key_for_bootstrapping),
741 setup_for_test_mode(setup_for_test_mode), 745 setup_for_test_mode(setup_for_test_mode),
742 unrecoverable_error_handler(unrecoverable_error_handler), 746 unrecoverable_error_handler(unrecoverable_error_handler),
743 report_unrecoverable_error_function( 747 report_unrecoverable_error_function(
744 report_unrecoverable_error_function) { 748 report_unrecoverable_error_function) {
745 } 749 }
746 750
747 SyncBackendHost::DoInitializeOptions::~DoInitializeOptions() {} 751 SyncBackendHost::DoInitializeOptions::~DoInitializeOptions() {}
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 options.event_handler, 968 options.event_handler,
965 options.service_url.host() + options.service_url.path(), 969 options.service_url.host() + options.service_url.path(),
966 options.service_url.EffectiveIntPort(), 970 options.service_url.EffectiveIntPort(),
967 options.service_url.SchemeIsSecure(), 971 options.service_url.SchemeIsSecure(),
968 options.make_http_bridge_factory_fn.Run(), 972 options.make_http_bridge_factory_fn.Run(),
969 options.registrar /* as ModelSafeWorkerRegistrar */, 973 options.registrar /* as ModelSafeWorkerRegistrar */,
970 options.extensions_activity_monitor, 974 options.extensions_activity_monitor,
971 options.registrar /* as SyncManager::ChangeDelegate */, 975 options.registrar /* as SyncManager::ChangeDelegate */,
972 MakeUserAgentForSyncApi(), 976 MakeUserAgentForSyncApi(),
973 options.credentials, 977 options.credentials,
974 options.sync_notifier_factory->CreateSyncNotifier(), 978 new BridgedSyncNotifier(
979 options.chrome_sync_notification_bridge,
980 options.sync_notifier_factory->CreateSyncNotifier()),
975 options.restored_key_for_bootstrapping, 981 options.restored_key_for_bootstrapping,
976 options.setup_for_test_mode, 982 options.setup_for_test_mode,
977 &encryptor_, 983 &encryptor_,
978 options.unrecoverable_error_handler, 984 options.unrecoverable_error_handler,
979 options.report_unrecoverable_error_function); 985 options.report_unrecoverable_error_function);
980 LOG_IF(ERROR, !success) << "Syncapi initialization failed!"; 986 LOG_IF(ERROR, !success) << "Syncapi initialization failed!";
981 } 987 }
982 988
983 void SyncBackendHost::Core::DoUpdateCredentials( 989 void SyncBackendHost::Core::DoUpdateCredentials(
984 const SyncCredentials& credentials) { 990 const SyncCredentials& credentials) {
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 FROM_HERE, 1312 FROM_HERE,
1307 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, 1313 base::Bind(&SyncBackendHost::Core::DoRefreshNigori,
1308 core_.get(), sync_thread_done_callback)); 1314 core_.get(), sync_thread_done_callback));
1309 } 1315 }
1310 1316
1311 #undef SDVLOG 1317 #undef SDVLOG
1312 1318
1313 #undef SLOG 1319 #undef SLOG
1314 1320
1315 } // namespace browser_sync 1321 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host.h ('k') | chrome/browser/sync/notifier/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698