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 22 matching lines...) Expand all Loading... |
61 #include "components/user_prefs/pref_registry_syncable.h" | 62 #include "components/user_prefs/pref_registry_syncable.h" |
62 #include "content/public/browser/notification_details.h" | 63 #include "content/public/browser/notification_details.h" |
63 #include "content/public/browser/notification_service.h" | 64 #include "content/public/browser/notification_service.h" |
64 #include "content/public/browser/notification_source.h" | 65 #include "content/public/browser/notification_source.h" |
65 #include "google_apis/gaia/gaia_constants.h" | 66 #include "google_apis/gaia/gaia_constants.h" |
66 #include "grit/generated_resources.h" | 67 #include "grit/generated_resources.h" |
67 #include "net/cookies/cookie_monster.h" | 68 #include "net/cookies/cookie_monster.h" |
68 #include "net/url_request/url_request_context_getter.h" | 69 #include "net/url_request/url_request_context_getter.h" |
69 #include "sync/api/sync_error.h" | 70 #include "sync/api/sync_error.h" |
70 #include "sync/internal_api/public/configure_reason.h" | 71 #include "sync/internal_api/public/configure_reason.h" |
| 72 #include "sync/internal_api/public/http_bridge.h" |
| 73 #include "sync/internal_api/public/http_post_provider_factory.h" |
71 #include "sync/internal_api/public/sync_encryption_handler.h" | 74 #include "sync/internal_api/public/sync_encryption_handler.h" |
72 #include "sync/internal_api/public/util/experiments.h" | 75 #include "sync/internal_api/public/util/experiments.h" |
73 #include "sync/internal_api/public/util/sync_string_conversions.h" | 76 #include "sync/internal_api/public/util/sync_string_conversions.h" |
74 #include "sync/js/js_arg_list.h" | 77 #include "sync/js/js_arg_list.h" |
75 #include "sync/js/js_event_details.h" | 78 #include "sync/js/js_event_details.h" |
76 #include "sync/util/cryptographer.h" | 79 #include "sync/util/cryptographer.h" |
77 #include "ui/base/l10n/l10n_util.h" | 80 #include "ui/base/l10n/l10n_util.h" |
78 #include "ui/base/l10n/time_format.h" | 81 #include "ui/base/l10n/time_format.h" |
79 | 82 |
80 #if defined(ENABLE_MANAGED_USERS) | 83 #if defined(ENABLE_MANAGED_USERS) |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 profile_->GetRequestContext()); | 486 profile_->GetRequestContext()); |
484 | 487 |
485 if (delete_stale_data) | 488 if (delete_stale_data) |
486 ClearStaleErrors(); | 489 ClearStaleErrors(); |
487 | 490 |
488 scoped_ptr<syncer::UnrecoverableErrorHandler> | 491 scoped_ptr<syncer::UnrecoverableErrorHandler> |
489 backend_unrecoverable_error_handler( | 492 backend_unrecoverable_error_handler( |
490 new browser_sync::BackendUnrecoverableErrorHandler( | 493 new browser_sync::BackendUnrecoverableErrorHandler( |
491 MakeWeakHandle(weak_factory_.GetWeakPtr()))); | 494 MakeWeakHandle(weak_factory_.GetWeakPtr()))); |
492 | 495 |
| 496 // Consider overriding a function instead of doing this here. |
| 497 if (http_post_provider_factory_.get() == NULL) |
| 498 http_post_provider_factory_.reset(new syncer::HttpBridgeFactory( |
| 499 make_scoped_refptr(profile_->GetRequestContext()), |
| 500 NetworkTimeTracker::BuildNotifierUpdateCallback())); |
| 501 |
493 backend_->Initialize( | 502 backend_->Initialize( |
494 this, | 503 this, |
495 sync_thread_.Pass(), | 504 sync_thread_.Pass(), |
496 GetJsEventHandler(), | 505 GetJsEventHandler(), |
497 sync_service_url_, | 506 sync_service_url_, |
498 credentials, | 507 credentials, |
499 delete_stale_data, | 508 delete_stale_data, |
500 scoped_ptr<syncer::SyncManagerFactory>( | 509 scoped_ptr<syncer::SyncManagerFactory>( |
501 new syncer::SyncManagerFactory).Pass(), | 510 new syncer::SyncManagerFactory).Pass(), |
502 backend_unrecoverable_error_handler.Pass(), | 511 backend_unrecoverable_error_handler.Pass(), |
503 &browser_sync::ChromeReportUnrecoverableError); | 512 &browser_sync::ChromeReportUnrecoverableError, |
| 513 http_post_provider_factory_.Pass()); |
504 } | 514 } |
505 | 515 |
506 void ProfileSyncService::CreateBackend() { | 516 void ProfileSyncService::CreateBackend() { |
507 backend_.reset( | 517 backend_.reset( |
508 factory_->CreateSyncBackendHost( | 518 factory_->CreateSyncBackendHost( |
509 profile_->GetDebugName(), | 519 profile_->GetDebugName(), |
510 profile_, | 520 profile_, |
511 sync_prefs_.AsWeakPtr())); | 521 sync_prefs_.AsWeakPtr())); |
512 } | 522 } |
513 | 523 |
(...skipping 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2207 SyncTokenStatus status; | 2217 SyncTokenStatus status; |
2208 status.connection_status_update_time = connection_status_update_time_; | 2218 status.connection_status_update_time = connection_status_update_time_; |
2209 status.connection_status = connection_status_; | 2219 status.connection_status = connection_status_; |
2210 status.token_request_time = token_request_time_; | 2220 status.token_request_time = token_request_time_; |
2211 status.token_receive_time = token_receive_time_; | 2221 status.token_receive_time = token_receive_time_; |
2212 status.last_get_token_error = last_get_token_error_; | 2222 status.last_get_token_error = last_get_token_error_; |
2213 if (request_access_token_retry_timer_.IsRunning()) | 2223 if (request_access_token_retry_timer_.IsRunning()) |
2214 status.next_token_request_time = next_token_request_time_; | 2224 status.next_token_request_time = next_token_request_time_; |
2215 return status; | 2225 return status; |
2216 } | 2226 } |
| 2227 |
| 2228 void ProfileSyncService::OverrideHttpPostProviderFactoryForTest( |
| 2229 syncer::HttpPostProviderFactory* http_post_provider_factory) { |
| 2230 http_post_provider_factory_.reset(http_post_provider_factory); |
| 2231 } |
OLD | NEW |