Chromium Code Reviews| 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/test_profile_sync_service.h" | 5 #include "chrome/browser/sync/test_profile_sync_service.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/signin/signin_manager.h" | 8 #include "chrome/browser/signin/signin_manager.h" |
| 9 #include "chrome/browser/signin/signin_manager_factory.h" | 9 #include "chrome/browser/signin/signin_manager_factory.h" |
| 10 #include "chrome/browser/sync/glue/sync_backend_host.h" | 10 #include "chrome/browser/sync/glue/sync_backend_host.h" |
| 11 #include "chrome/browser/sync/glue/sync_backend_host_core.h" | |
|
Nicolas Zea
2013/11/06 18:03:21
is this necessary?
rlarocque
2013/11/06 21:48:47
Yeah, for DoInitializeOptions. This may be an arg
| |
| 11 #include "chrome/browser/sync/profile_sync_components_factory.h" | 12 #include "chrome/browser/sync/profile_sync_components_factory.h" |
| 12 #include "chrome/browser/sync/test/test_http_bridge_factory.h" | 13 #include "chrome/browser/sync/test/test_http_bridge_factory.h" |
| 13 #include "sync/internal_api/public/test/sync_manager_factory_for_profile_sync_te st.h" | 14 #include "sync/internal_api/public/test/sync_manager_factory_for_profile_sync_te st.h" |
| 14 #include "sync/internal_api/public/user_share.h" | 15 #include "sync/internal_api/public/user_share.h" |
| 15 #include "sync/js/js_reply_handler.h" | 16 #include "sync/js/js_reply_handler.h" |
| 16 #include "sync/protocol/encryption.pb.h" | 17 #include "sync/protocol/encryption.pb.h" |
| 17 | 18 |
| 18 using syncer::InternalComponentsFactory; | 19 using syncer::InternalComponentsFactory; |
| 19 using syncer::ModelSafeRoutingInfo; | 20 using syncer::ModelSafeRoutingInfo; |
| 20 using syncer::TestInternalComponentsFactory; | 21 using syncer::TestInternalComponentsFactory; |
| 21 using syncer::UserShare; | 22 using syncer::UserShare; |
| 22 | 23 |
| 23 namespace browser_sync { | 24 namespace browser_sync { |
| 24 | 25 |
| 25 SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( | 26 SyncBackendHostForProfileSyncTest::SyncBackendHostForProfileSyncTest( |
| 26 Profile* profile, | 27 Profile* profile, |
| 27 const base::WeakPtr<SyncPrefs>& sync_prefs, | 28 const base::WeakPtr<SyncPrefs>& sync_prefs, |
| 28 base::Closure& callback, | 29 base::Closure& callback, |
| 29 bool set_initial_sync_ended_on_init, | 30 bool set_initial_sync_ended_on_init, |
| 30 bool synchronous_init, | 31 bool synchronous_init, |
| 31 bool fail_initial_download, | 32 bool fail_initial_download, |
| 32 syncer::StorageOption storage_option) | 33 syncer::StorageOption storage_option) |
| 33 : browser_sync::SyncBackendHost( | 34 : browser_sync::SyncBackendHostImpl( |
| 34 profile->GetDebugName(), profile, sync_prefs), | 35 profile->GetDebugName(), profile, sync_prefs), |
| 35 callback_(callback), | 36 callback_(callback), |
| 36 fail_initial_download_(fail_initial_download), | 37 fail_initial_download_(fail_initial_download), |
| 37 set_initial_sync_ended_on_init_(set_initial_sync_ended_on_init), | 38 set_initial_sync_ended_on_init_(set_initial_sync_ended_on_init), |
| 38 synchronous_init_(synchronous_init), | 39 synchronous_init_(synchronous_init), |
| 39 storage_option_(storage_option), | 40 storage_option_(storage_option), |
| 40 weak_ptr_factory_(this) {} | 41 weak_ptr_factory_(this) {} |
| 41 | 42 |
| 42 SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} | 43 SyncBackendHostForProfileSyncTest::~SyncBackendHostForProfileSyncTest() {} |
| 43 | 44 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 63 syncer::StorageOption storage = storage_option_; | 64 syncer::StorageOption storage = storage_option_; |
| 64 | 65 |
| 65 // It'd be nice if we avoided creating the InternalComponentsFactory in the | 66 // It'd be nice if we avoided creating the InternalComponentsFactory in the |
| 66 // first place, but SyncBackendHost will have created one by now so we must | 67 // first place, but SyncBackendHost will have created one by now so we must |
| 67 // free it. Grab the switches to pass on first. | 68 // free it. Grab the switches to pass on first. |
| 68 InternalComponentsFactory::Switches factory_switches = | 69 InternalComponentsFactory::Switches factory_switches = |
| 69 options->internal_components_factory->GetSwitches(); | 70 options->internal_components_factory->GetSwitches(); |
| 70 options->internal_components_factory.reset( | 71 options->internal_components_factory.reset( |
| 71 new TestInternalComponentsFactory(factory_switches, storage)); | 72 new TestInternalComponentsFactory(factory_switches, storage)); |
| 72 | 73 |
| 73 SyncBackendHost::InitCore(options.Pass()); | 74 SyncBackendHostImpl::InitCore(options.Pass()); |
| 74 if (synchronous_init_ && !base::MessageLoop::current()->is_running()) { | 75 if (synchronous_init_ && !base::MessageLoop::current()->is_running()) { |
| 75 // The SyncBackend posts a task to the current loop when | 76 // The SyncBackend posts a task to the current loop when |
| 76 // initialization completes. | 77 // initialization completes. |
| 77 base::MessageLoop::current()->Run(); | 78 base::MessageLoop::current()->Run(); |
| 78 } | 79 } |
| 79 } | 80 } |
| 80 | 81 |
| 81 void SyncBackendHostForProfileSyncTest::UpdateCredentials( | 82 void SyncBackendHostForProfileSyncTest::UpdateCredentials( |
| 82 const syncer::SyncCredentials& credentials) { | 83 const syncer::SyncCredentials& credentials) { |
| 83 // If we had failed the initial download, complete initialization now. | 84 // If we had failed the initial download, complete initialization now. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 initial_download_closure_ = base::Bind( | 124 initial_download_closure_ = base::Bind( |
| 124 &SyncBackendHostForProfileSyncTest:: | 125 &SyncBackendHostForProfileSyncTest:: |
| 125 HandleInitializationSuccessOnFrontendLoop, | 126 HandleInitializationSuccessOnFrontendLoop, |
| 126 weak_ptr_factory_.GetWeakPtr(), | 127 weak_ptr_factory_.GetWeakPtr(), |
| 127 js_backend, | 128 js_backend, |
| 128 debug_info_listener); | 129 debug_info_listener); |
| 129 HandleControlTypesDownloadRetry(); | 130 HandleControlTypesDownloadRetry(); |
| 130 if (synchronous_init_) | 131 if (synchronous_init_) |
| 131 base::MessageLoop::current()->Quit(); | 132 base::MessageLoop::current()->Quit(); |
| 132 } else { | 133 } else { |
| 133 SyncBackendHost::HandleInitializationSuccessOnFrontendLoop( | 134 SyncBackendHostImpl::HandleInitializationSuccessOnFrontendLoop( |
| 134 js_backend, | 135 js_backend, |
| 135 debug_info_listener); | 136 debug_info_listener); |
| 136 } | 137 } |
| 137 } | 138 } |
| 138 | 139 |
| 139 } // namespace browser_sync | 140 } // namespace browser_sync |
| 140 | 141 |
| 141 syncer::TestIdFactory* TestProfileSyncService::id_factory() { | 142 syncer::TestIdFactory* TestProfileSyncService::id_factory() { |
| 142 return &id_factory_; | 143 return &id_factory_; |
| 143 } | 144 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 void FakeOAuth2TokenService::PersistCredentials( | 298 void FakeOAuth2TokenService::PersistCredentials( |
| 298 const std::string& account_id, | 299 const std::string& account_id, |
| 299 const std::string& refresh_token) { | 300 const std::string& refresh_token) { |
| 300 // Disabling the token persistence. | 301 // Disabling the token persistence. |
| 301 } | 302 } |
| 302 | 303 |
| 303 void FakeOAuth2TokenService::ClearPersistedCredentials( | 304 void FakeOAuth2TokenService::ClearPersistedCredentials( |
| 304 const std::string& account_id) { | 305 const std::string& account_id) { |
| 305 // Disabling the token persistence. | 306 // Disabling the token persistence. |
| 306 } | 307 } |
| OLD | NEW |