OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/file_version_info.h" | 7 #include "base/file_version_info.h" |
8 #include "base/task.h" | 8 #include "base/task.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/app/chrome_version_info.h" | 10 #include "chrome/app/chrome_version_info.h" |
11 #include "chrome/browser/chrome_thread.h" | 11 #include "chrome/browser/chrome_thread.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 60 } |
61 | 61 |
62 SyncBackendHost::~SyncBackendHost() { | 62 SyncBackendHost::~SyncBackendHost() { |
63 DCHECK(!core_ && !frontend_) << "Must call Shutdown before destructor."; | 63 DCHECK(!core_ && !frontend_) << "Must call Shutdown before destructor."; |
64 DCHECK(registrar_.workers.empty()); | 64 DCHECK(registrar_.workers.empty()); |
65 } | 65 } |
66 | 66 |
67 void SyncBackendHost::Initialize( | 67 void SyncBackendHost::Initialize( |
68 const GURL& sync_service_url, | 68 const GURL& sync_service_url, |
69 const syncable::ModelTypeSet& types, | 69 const syncable::ModelTypeSet& types, |
70 chrome_common_net::NetworkChangeNotifierThread* | |
71 network_change_notifier_thread, | |
72 URLRequestContextGetter* baseline_context_getter, | 70 URLRequestContextGetter* baseline_context_getter, |
73 const std::string& lsid, | 71 const std::string& lsid, |
74 bool delete_sync_data_folder, | 72 bool delete_sync_data_folder, |
75 bool invalidate_sync_login, | 73 bool invalidate_sync_login, |
76 bool invalidate_sync_xmpp_login, | 74 bool invalidate_sync_xmpp_login, |
77 NotificationMethod notification_method) { | 75 NotificationMethod notification_method) { |
78 if (!core_thread_.Start()) | 76 if (!core_thread_.Start()) |
79 return; | 77 return; |
80 | 78 |
81 // Create a worker for the UI thread and route bookmark changes to it. | 79 // Create a worker for the UI thread and route bookmark changes to it. |
(...skipping 18 matching lines...) Expand all Loading... |
100 for (syncable::ModelTypeSet::const_iterator it = types.begin(); | 98 for (syncable::ModelTypeSet::const_iterator it = types.begin(); |
101 it != types.end(); ++it) { | 99 it != types.end(); ++it) { |
102 registrar_.routing_info[(*it)] = GROUP_PASSIVE; | 100 registrar_.routing_info[(*it)] = GROUP_PASSIVE; |
103 } | 101 } |
104 registrar_.routing_info[syncable::NIGORI] = GROUP_PASSIVE; | 102 registrar_.routing_info[syncable::NIGORI] = GROUP_PASSIVE; |
105 | 103 |
106 core_thread_.message_loop()->PostTask(FROM_HERE, | 104 core_thread_.message_loop()->PostTask(FROM_HERE, |
107 NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoInitialize, | 105 NewRunnableMethod(core_.get(), &SyncBackendHost::Core::DoInitialize, |
108 Core::DoInitializeOptions( | 106 Core::DoInitializeOptions( |
109 sync_service_url, true, | 107 sync_service_url, true, |
110 network_change_notifier_thread, | |
111 new HttpBridgeFactory(baseline_context_getter), | 108 new HttpBridgeFactory(baseline_context_getter), |
112 new HttpBridgeFactory(baseline_context_getter), | 109 new HttpBridgeFactory(baseline_context_getter), |
113 lsid, | 110 lsid, |
114 delete_sync_data_folder, | 111 delete_sync_data_folder, |
115 invalidate_sync_login, | 112 invalidate_sync_login, |
116 invalidate_sync_xmpp_login, | 113 invalidate_sync_xmpp_login, |
117 notification_method))); | 114 notification_method))); |
118 } | 115 } |
119 | 116 |
120 void SyncBackendHost::Authenticate(const std::string& username, | 117 void SyncBackendHost::Authenticate(const std::string& username, |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 DCHECK(success); | 382 DCHECK(success); |
386 | 383 |
387 syncapi_->SetObserver(this); | 384 syncapi_->SetObserver(this); |
388 const FilePath& path_str = host_->sync_data_folder_path(); | 385 const FilePath& path_str = host_->sync_data_folder_path(); |
389 success = syncapi_->Init(path_str, | 386 success = syncapi_->Init(path_str, |
390 (options.service_url.host() + options.service_url.path()).c_str(), | 387 (options.service_url.host() + options.service_url.path()).c_str(), |
391 options.service_url.EffectiveIntPort(), | 388 options.service_url.EffectiveIntPort(), |
392 kGaiaServiceId, | 389 kGaiaServiceId, |
393 kGaiaSourceForChrome, | 390 kGaiaSourceForChrome, |
394 options.service_url.SchemeIsSecure(), | 391 options.service_url.SchemeIsSecure(), |
395 options.network_change_notifier_thread, | |
396 options.http_bridge_factory, | 392 options.http_bridge_factory, |
397 options.auth_http_bridge_factory, | 393 options.auth_http_bridge_factory, |
398 host_, // ModelSafeWorkerRegistrar. | 394 host_, // ModelSafeWorkerRegistrar. |
399 options.attempt_last_user_authentication, | 395 options.attempt_last_user_authentication, |
400 options.invalidate_sync_login, | 396 options.invalidate_sync_login, |
401 options.invalidate_sync_xmpp_login, | 397 options.invalidate_sync_xmpp_login, |
402 MakeUserAgentForSyncapi().c_str(), | 398 MakeUserAgentForSyncapi().c_str(), |
403 options.lsid.c_str(), | 399 options.lsid.c_str(), |
404 options.notification_method); | 400 options.notification_method); |
405 DCHECK(success) << "Syncapi initialization failed!"; | 401 DCHECK(success) << "Syncapi initialization failed!"; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 } | 605 } |
610 | 606 |
611 void SyncBackendHost::Core::DeleteSyncDataFolder() { | 607 void SyncBackendHost::Core::DeleteSyncDataFolder() { |
612 if (file_util::DirectoryExists(host_->sync_data_folder_path())) { | 608 if (file_util::DirectoryExists(host_->sync_data_folder_path())) { |
613 if (!file_util::Delete(host_->sync_data_folder_path(), true)) | 609 if (!file_util::Delete(host_->sync_data_folder_path(), true)) |
614 LOG(DFATAL) << "Could not delete the Sync Data folder."; | 610 LOG(DFATAL) << "Could not delete the Sync Data folder."; |
615 } | 611 } |
616 } | 612 } |
617 | 613 |
618 } // namespace browser_sync | 614 } // namespace browser_sync |
OLD | NEW |