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

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: 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
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/http_bridge.h" 25 #include "chrome/browser/sync/glue/http_bridge.h"
25 #include "chrome/browser/sync/glue/sync_backend_registrar.h" 26 #include "chrome/browser/sync/glue/sync_backend_registrar.h"
26 #include "chrome/browser/sync/internal_api/base_transaction.h" 27 #include "chrome/browser/sync/internal_api/base_transaction.h"
27 #include "chrome/browser/sync/internal_api/read_transaction.h" 28 #include "chrome/browser/sync/internal_api/read_transaction.h"
28 #include "chrome/browser/sync/notifier/sync_notifier.h" 29 #include "chrome/browser/sync/notifier/sync_notifier.h"
29 #include "chrome/browser/sync/protocol/encryption.pb.h" 30 #include "chrome/browser/sync/protocol/encryption.pb.h"
30 #include "chrome/browser/sync/protocol/sync.pb.h" 31 #include "chrome/browser/sync/protocol/sync.pb.h"
31 #include "chrome/browser/sync/sessions/session_state.h" 32 #include "chrome/browser/sync/sessions/session_state.h"
32 #include "chrome/browser/sync/sync_prefs.h" 33 #include "chrome/browser/sync/sync_prefs.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 const base::WeakPtr<SyncPrefs>& sync_prefs) 224 const base::WeakPtr<SyncPrefs>& sync_prefs)
224 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 225 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
225 sync_thread_("Chrome_SyncThread"), 226 sync_thread_("Chrome_SyncThread"),
226 frontend_loop_(MessageLoop::current()), 227 frontend_loop_(MessageLoop::current()),
227 profile_(profile), 228 profile_(profile),
228 name_(name), 229 name_(name),
229 core_(new Core(name, profile_->GetPath().Append(kSyncDataFolderName), 230 core_(new Core(name, profile_->GetPath().Append(kSyncDataFolderName),
230 weak_ptr_factory_.GetWeakPtr())), 231 weak_ptr_factory_.GetWeakPtr())),
231 initialization_state_(NOT_ATTEMPTED), 232 initialization_state_(NOT_ATTEMPTED),
232 sync_prefs_(sync_prefs), 233 sync_prefs_(sync_prefs),
234 chrome_sync_notification_bridge_(profile_),
233 sync_notifier_factory_( 235 sync_notifier_factory_(
234 profile_,
235 content::GetUserAgent(GURL()), 236 content::GetUserAgent(GURL()),
236 profile_->GetRequestContext(), 237 profile_->GetRequestContext(),
237 sync_prefs, 238 sync_prefs,
238 *CommandLine::ForCurrentProcess()), 239 *CommandLine::ForCurrentProcess()),
239 frontend_(NULL), 240 frontend_(NULL),
240 last_auth_error_(AuthError::None()) { 241 last_auth_error_(AuthError::None()) {
241 } 242 }
242 243
243 SyncBackendHost::SyncBackendHost(Profile* profile) 244 SyncBackendHost::SyncBackendHost(Profile* profile)
244 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 245 : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
245 sync_thread_("Chrome_SyncThread"), 246 sync_thread_("Chrome_SyncThread"),
246 frontend_loop_(MessageLoop::current()), 247 frontend_loop_(MessageLoop::current()),
247 profile_(profile), 248 profile_(profile),
248 name_("Unknown"), 249 name_("Unknown"),
249 initialization_state_(NOT_ATTEMPTED), 250 initialization_state_(NOT_ATTEMPTED),
251 chrome_sync_notification_bridge_(profile_),
250 sync_notifier_factory_( 252 sync_notifier_factory_(
251 profile_,
252 content::GetUserAgent(GURL()), 253 content::GetUserAgent(GURL()),
253 NULL, 254 NULL,
254 base::WeakPtr<sync_notifier::InvalidationVersionTracker>(), 255 base::WeakPtr<sync_notifier::InvalidationVersionTracker>(),
255 *CommandLine::ForCurrentProcess()), 256 *CommandLine::ForCurrentProcess()),
256 frontend_(NULL), 257 frontend_(NULL),
257 last_auth_error_(AuthError::None()) { 258 last_auth_error_(AuthError::None()) {
258 } 259 }
259 260
260 SyncBackendHost::~SyncBackendHost() { 261 SyncBackendHost::~SyncBackendHost() {
261 DCHECK(!core_ && !frontend_) << "Must call Shutdown before destructor."; 262 DCHECK(!core_ && !frontend_) << "Must call Shutdown before destructor.";
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 initialization_state_ = CREATING_SYNC_MANAGER; 300 initialization_state_ = CREATING_SYNC_MANAGER;
300 InitCore(DoInitializeOptions( 301 InitCore(DoInitializeOptions(
301 sync_thread_.message_loop(), 302 sync_thread_.message_loop(),
302 registrar_.get(), 303 registrar_.get(),
303 &extensions_activity_monitor_, 304 &extensions_activity_monitor_,
304 event_handler, 305 event_handler,
305 sync_service_url, 306 sync_service_url,
306 base::Bind(&MakeHttpBridgeFactory, 307 base::Bind(&MakeHttpBridgeFactory,
307 make_scoped_refptr(profile_->GetRequestContext())), 308 make_scoped_refptr(profile_->GetRequestContext())),
308 credentials, 309 credentials,
310 &chrome_sync_notification_bridge_,
309 &sync_notifier_factory_, 311 &sync_notifier_factory_,
310 delete_sync_data_folder, 312 delete_sync_data_folder,
311 sync_prefs_->GetEncryptionBootstrapToken(), 313 sync_prefs_->GetEncryptionBootstrapToken(),
312 false, 314 false,
313 unrecoverable_error_handler, 315 unrecoverable_error_handler,
314 report_unrecoverable_error_function)); 316 report_unrecoverable_error_function));
315 } 317 }
316 318
317 void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) { 319 void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) {
318 sync_thread_.message_loop()->PostTask(FROM_HERE, 320 sync_thread_.message_loop()->PostTask(FROM_HERE,
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 } 713 }
712 714
713 SyncBackendHost::DoInitializeOptions::DoInitializeOptions( 715 SyncBackendHost::DoInitializeOptions::DoInitializeOptions(
714 MessageLoop* sync_loop, 716 MessageLoop* sync_loop,
715 SyncBackendRegistrar* registrar, 717 SyncBackendRegistrar* registrar,
716 ExtensionsActivityMonitor* extensions_activity_monitor, 718 ExtensionsActivityMonitor* extensions_activity_monitor,
717 const WeakHandle<JsEventHandler>& event_handler, 719 const WeakHandle<JsEventHandler>& event_handler,
718 const GURL& service_url, 720 const GURL& service_url,
719 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn, 721 MakeHttpBridgeFactoryFn make_http_bridge_factory_fn,
720 const sync_api::SyncCredentials& credentials, 722 const sync_api::SyncCredentials& credentials,
723 ChromeSyncNotificationBridge* chrome_sync_notification_bridge,
721 sync_notifier::SyncNotifierFactory* sync_notifier_factory, 724 sync_notifier::SyncNotifierFactory* sync_notifier_factory,
722 bool delete_sync_data_folder, 725 bool delete_sync_data_folder,
723 const std::string& restored_key_for_bootstrapping, 726 const std::string& restored_key_for_bootstrapping,
724 bool setup_for_test_mode, 727 bool setup_for_test_mode,
725 UnrecoverableErrorHandler* unrecoverable_error_handler, 728 UnrecoverableErrorHandler* unrecoverable_error_handler,
726 ReportUnrecoverableErrorFunction report_unrecoverable_error_function) 729 ReportUnrecoverableErrorFunction report_unrecoverable_error_function)
727 : sync_loop(sync_loop), 730 : sync_loop(sync_loop),
728 registrar(registrar), 731 registrar(registrar),
729 extensions_activity_monitor(extensions_activity_monitor), 732 extensions_activity_monitor(extensions_activity_monitor),
730 event_handler(event_handler), 733 event_handler(event_handler),
731 service_url(service_url), 734 service_url(service_url),
732 make_http_bridge_factory_fn(make_http_bridge_factory_fn), 735 make_http_bridge_factory_fn(make_http_bridge_factory_fn),
733 credentials(credentials), 736 credentials(credentials),
737 chrome_sync_notification_bridge(chrome_sync_notification_bridge),
734 sync_notifier_factory(sync_notifier_factory), 738 sync_notifier_factory(sync_notifier_factory),
735 delete_sync_data_folder(delete_sync_data_folder), 739 delete_sync_data_folder(delete_sync_data_folder),
736 restored_key_for_bootstrapping(restored_key_for_bootstrapping), 740 restored_key_for_bootstrapping(restored_key_for_bootstrapping),
737 setup_for_test_mode(setup_for_test_mode), 741 setup_for_test_mode(setup_for_test_mode),
738 unrecoverable_error_handler(unrecoverable_error_handler), 742 unrecoverable_error_handler(unrecoverable_error_handler),
739 report_unrecoverable_error_function( 743 report_unrecoverable_error_function(
740 report_unrecoverable_error_function) { 744 report_unrecoverable_error_function) {
741 } 745 }
742 746
743 SyncBackendHost::DoInitializeOptions::~DoInitializeOptions() {} 747 SyncBackendHost::DoInitializeOptions::~DoInitializeOptions() {}
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 options.event_handler, 964 options.event_handler,
961 options.service_url.host() + options.service_url.path(), 965 options.service_url.host() + options.service_url.path(),
962 options.service_url.EffectiveIntPort(), 966 options.service_url.EffectiveIntPort(),
963 options.service_url.SchemeIsSecure(), 967 options.service_url.SchemeIsSecure(),
964 options.make_http_bridge_factory_fn.Run(), 968 options.make_http_bridge_factory_fn.Run(),
965 options.registrar /* as ModelSafeWorkerRegistrar */, 969 options.registrar /* as ModelSafeWorkerRegistrar */,
966 options.extensions_activity_monitor, 970 options.extensions_activity_monitor,
967 options.registrar /* as SyncManager::ChangeDelegate */, 971 options.registrar /* as SyncManager::ChangeDelegate */,
968 MakeUserAgentForSyncApi(), 972 MakeUserAgentForSyncApi(),
969 options.credentials, 973 options.credentials,
970 options.sync_notifier_factory->CreateSyncNotifier(), 974 new BridgedSyncNotifier(
975 options.chrome_sync_notification_bridge,
976 options.sync_notifier_factory->CreateSyncNotifier()),
971 options.restored_key_for_bootstrapping, 977 options.restored_key_for_bootstrapping,
972 options.setup_for_test_mode, 978 options.setup_for_test_mode,
973 options.unrecoverable_error_handler, 979 options.unrecoverable_error_handler,
974 options.report_unrecoverable_error_function); 980 options.report_unrecoverable_error_function);
975 LOG_IF(ERROR, !success) << "Syncapi initialization failed!"; 981 LOG_IF(ERROR, !success) << "Syncapi initialization failed!";
976 } 982 }
977 983
978 void SyncBackendHost::Core::DoUpdateCredentials( 984 void SyncBackendHost::Core::DoUpdateCredentials(
979 const SyncCredentials& credentials) { 985 const SyncCredentials& credentials) {
980 DCHECK_EQ(MessageLoop::current(), sync_loop_); 986 DCHECK_EQ(MessageLoop::current(), sync_loop_);
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 FROM_HERE, 1307 FROM_HERE,
1302 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, 1308 base::Bind(&SyncBackendHost::Core::DoRefreshNigori,
1303 core_.get(), sync_thread_done_callback)); 1309 core_.get(), sync_thread_done_callback));
1304 } 1310 }
1305 1311
1306 #undef SDVLOG 1312 #undef SDVLOG
1307 1313
1308 #undef SLOG 1314 #undef SLOG
1309 1315
1310 } // namespace browser_sync 1316 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698