OLD | NEW |
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 "chrome/browser/sync/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
20 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
21 #include "base/strings/string16.h" | 21 #include "base/strings/string16.h" |
22 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
23 #include "base/threading/thread_restrictions.h" | 23 #include "base/threading/thread_restrictions.h" |
24 #include "build/build_config.h" | 24 #include "build/build_config.h" |
25 #include "chrome/browser/browser_process.h" | 25 #include "chrome/browser/browser_process.h" |
26 #include "chrome/browser/chrome_notification_types.h" | 26 #include "chrome/browser/chrome_notification_types.h" |
27 #include "chrome/browser/defaults.h" | 27 #include "chrome/browser/defaults.h" |
28 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 28 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
| 29 #include "chrome/browser/network_time/network_time_tracker.h" |
29 #include "chrome/browser/prefs/pref_service_syncable.h" | 30 #include "chrome/browser/prefs/pref_service_syncable.h" |
30 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
31 #include "chrome/browser/signin/about_signin_internals.h" | 32 #include "chrome/browser/signin/about_signin_internals.h" |
32 #include "chrome/browser/signin/about_signin_internals_factory.h" | 33 #include "chrome/browser/signin/about_signin_internals_factory.h" |
33 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 34 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
34 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 35 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
35 #include "chrome/browser/signin/signin_manager.h" | 36 #include "chrome/browser/signin/signin_manager.h" |
36 #include "chrome/browser/signin/signin_manager_factory.h" | 37 #include "chrome/browser/signin/signin_manager_factory.h" |
37 #include "chrome/browser/sync/backend_migrator.h" | 38 #include "chrome/browser/sync/backend_migrator.h" |
38 #include "chrome/browser/sync/glue/change_processor.h" | 39 #include "chrome/browser/sync/glue/change_processor.h" |
(...skipping 24 matching lines...) Expand all Loading... |
63 #include "components/user_prefs/pref_registry_syncable.h" | 64 #include "components/user_prefs/pref_registry_syncable.h" |
64 #include "content/public/browser/notification_details.h" | 65 #include "content/public/browser/notification_details.h" |
65 #include "content/public/browser/notification_service.h" | 66 #include "content/public/browser/notification_service.h" |
66 #include "content/public/browser/notification_source.h" | 67 #include "content/public/browser/notification_source.h" |
67 #include "google_apis/gaia/gaia_constants.h" | 68 #include "google_apis/gaia/gaia_constants.h" |
68 #include "grit/generated_resources.h" | 69 #include "grit/generated_resources.h" |
69 #include "net/cookies/cookie_monster.h" | 70 #include "net/cookies/cookie_monster.h" |
70 #include "net/url_request/url_request_context_getter.h" | 71 #include "net/url_request/url_request_context_getter.h" |
71 #include "sync/api/sync_error.h" | 72 #include "sync/api/sync_error.h" |
72 #include "sync/internal_api/public/configure_reason.h" | 73 #include "sync/internal_api/public/configure_reason.h" |
| 74 #include "sync/internal_api/public/http_bridge_factory_factory.h" |
| 75 #include "sync/internal_api/public/http_post_provider_factory.h" |
| 76 #include "sync/internal_api/public/http_post_provider_factory_factory.h" |
73 #include "sync/internal_api/public/sync_encryption_handler.h" | 77 #include "sync/internal_api/public/sync_encryption_handler.h" |
74 #include "sync/internal_api/public/util/experiments.h" | 78 #include "sync/internal_api/public/util/experiments.h" |
75 #include "sync/internal_api/public/util/sync_string_conversions.h" | 79 #include "sync/internal_api/public/util/sync_string_conversions.h" |
76 #include "sync/js/js_arg_list.h" | 80 #include "sync/js/js_arg_list.h" |
77 #include "sync/js/js_event_details.h" | 81 #include "sync/js/js_event_details.h" |
78 #include "sync/util/cryptographer.h" | 82 #include "sync/util/cryptographer.h" |
79 #include "ui/base/l10n/l10n_util.h" | 83 #include "ui/base/l10n/l10n_util.h" |
80 #include "ui/base/l10n/time_format.h" | 84 #include "ui/base/l10n/time_format.h" |
81 | 85 |
82 #if defined(ENABLE_MANAGED_USERS) | 86 #if defined(ENABLE_MANAGED_USERS) |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()), | 176 encrypted_types_(syncer::SyncEncryptionHandler::SensitiveTypes()), |
173 encrypt_everything_(false), | 177 encrypt_everything_(false), |
174 encryption_pending_(false), | 178 encryption_pending_(false), |
175 auto_start_enabled_(start_behavior == AUTO_START), | 179 auto_start_enabled_(start_behavior == AUTO_START), |
176 configure_status_(DataTypeManager::UNKNOWN), | 180 configure_status_(DataTypeManager::UNKNOWN), |
177 setup_in_progress_(false), | 181 setup_in_progress_(false), |
178 oauth2_token_service_(oauth2_token_service), | 182 oauth2_token_service_(oauth2_token_service), |
179 request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy), | 183 request_access_token_backoff_(&kRequestAccessTokenBackoffPolicy), |
180 weak_factory_(this), | 184 weak_factory_(this), |
181 connection_status_(syncer::CONNECTION_NOT_ATTEMPTED), | 185 connection_status_(syncer::CONNECTION_NOT_ATTEMPTED), |
182 last_get_token_error_(GoogleServiceAuthError::AuthErrorNone()) { | 186 last_get_token_error_(GoogleServiceAuthError::AuthErrorNone()), |
| 187 http_post_provider_factory_factory_( |
| 188 new syncer::HttpBridgeFactoryFactory) { |
183 DCHECK(profile); | 189 DCHECK(profile); |
184 // By default, dev, canary, and unbranded Chromium users will go to the | 190 // By default, dev, canary, and unbranded Chromium users will go to the |
185 // development servers. Development servers have more features than standard | 191 // development servers. Development servers have more features than standard |
186 // sync servers. Users with officially-branded Chrome stable and beta builds | 192 // sync servers. Users with officially-branded Chrome stable and beta builds |
187 // will go to the standard sync servers. | 193 // will go to the standard sync servers. |
188 // | 194 // |
189 // GetChannel hits the registry on Windows. See http://crbug.com/70380. | 195 // GetChannel hits the registry on Windows. See http://crbug.com/70380. |
190 base::ThreadRestrictions::ScopedAllowIO allow_io; | 196 base::ThreadRestrictions::ScopedAllowIO allow_io; |
191 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 197 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
192 if (channel == chrome::VersionInfo::CHANNEL_STABLE || | 198 if (channel == chrome::VersionInfo::CHANNEL_STABLE || |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 backend_->Initialize( | 540 backend_->Initialize( |
535 this, | 541 this, |
536 sync_thread_.Pass(), | 542 sync_thread_.Pass(), |
537 GetJsEventHandler(), | 543 GetJsEventHandler(), |
538 sync_service_url_, | 544 sync_service_url_, |
539 credentials, | 545 credentials, |
540 delete_stale_data, | 546 delete_stale_data, |
541 scoped_ptr<syncer::SyncManagerFactory>( | 547 scoped_ptr<syncer::SyncManagerFactory>( |
542 new syncer::SyncManagerFactory).Pass(), | 548 new syncer::SyncManagerFactory).Pass(), |
543 backend_unrecoverable_error_handler.Pass(), | 549 backend_unrecoverable_error_handler.Pass(), |
544 &browser_sync::ChromeReportUnrecoverableError); | 550 &browser_sync::ChromeReportUnrecoverableError, |
| 551 make_scoped_ptr(http_post_provider_factory_factory_->Create( |
| 552 make_scoped_refptr(profile_->GetRequestContext()), |
| 553 NetworkTimeTracker::BuildNotifierUpdateCallback()))); |
545 } | 554 } |
546 | 555 |
547 void ProfileSyncService::CreateBackend() { | 556 void ProfileSyncService::CreateBackend() { |
548 backend_.reset( | 557 backend_.reset( |
549 factory_->CreateSyncBackendHost( | 558 factory_->CreateSyncBackendHost( |
550 profile_->GetDebugName(), | 559 profile_->GetDebugName(), |
551 profile_, | 560 profile_, |
552 sync_prefs_.AsWeakPtr())); | 561 sync_prefs_.AsWeakPtr())); |
553 } | 562 } |
554 | 563 |
(...skipping 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2252 SyncTokenStatus status; | 2261 SyncTokenStatus status; |
2253 status.connection_status_update_time = connection_status_update_time_; | 2262 status.connection_status_update_time = connection_status_update_time_; |
2254 status.connection_status = connection_status_; | 2263 status.connection_status = connection_status_; |
2255 status.token_request_time = token_request_time_; | 2264 status.token_request_time = token_request_time_; |
2256 status.token_receive_time = token_receive_time_; | 2265 status.token_receive_time = token_receive_time_; |
2257 status.last_get_token_error = last_get_token_error_; | 2266 status.last_get_token_error = last_get_token_error_; |
2258 if (request_access_token_retry_timer_.IsRunning()) | 2267 if (request_access_token_retry_timer_.IsRunning()) |
2259 status.next_token_request_time = next_token_request_time_; | 2268 status.next_token_request_time = next_token_request_time_; |
2260 return status; | 2269 return status; |
2261 } | 2270 } |
| 2271 |
| 2272 void ProfileSyncService::OverrideHttpPostProviderFactoryFactoryForTest( |
| 2273 syncer::HttpPostProviderFactoryFactory* |
| 2274 http_post_provider_factory_factory) { |
| 2275 http_post_provider_factory_factory_ = http_post_provider_factory_factory; |
| 2276 } |
OLD | NEW |