| 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 "components/browser_sync/profile_sync_service.h" | 5 #include "components/browser_sync/profile_sync_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 ProfileSyncService* service_; | 98 ProfileSyncService* service_; |
| 99 bool setup_in_progress_; | 99 bool setup_in_progress_; |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 // A variant of the SyncBackendHostMock that won't automatically | 102 // A variant of the SyncBackendHostMock that won't automatically |
| 103 // call back when asked to initialized. Allows us to test things | 103 // call back when asked to initialized. Allows us to test things |
| 104 // that could happen while backend init is in progress. | 104 // that could happen while backend init is in progress. |
| 105 class SyncBackendHostNoReturn : public SyncBackendHostMock { | 105 class SyncBackendHostNoReturn : public SyncBackendHostMock { |
| 106 void Initialize( | 106 void Initialize( |
| 107 syncer::SyncFrontend* frontend, | 107 syncer::SyncFrontend* frontend, |
| 108 base::Thread* sync_thread, | 108 scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner, |
| 109 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, | 109 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
| 110 const GURL& service_url, | 110 const GURL& service_url, |
| 111 const std::string& sync_user_agent, | 111 const std::string& sync_user_agent, |
| 112 const syncer::SyncCredentials& credentials, | 112 const syncer::SyncCredentials& credentials, |
| 113 bool delete_sync_data_folder, | 113 bool delete_sync_data_folder, |
| 114 bool enable_local_sync_backend, | 114 bool enable_local_sync_backend, |
| 115 const base::FilePath& local_sync_backend_folder, | 115 const base::FilePath& local_sync_backend_folder, |
| 116 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory, | 116 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory, |
| 117 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& | 117 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& |
| 118 unrecoverable_error_handler, | 118 unrecoverable_error_handler, |
| 119 const base::Closure& report_unrecoverable_error_function, | 119 const base::Closure& report_unrecoverable_error_function, |
| 120 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, | 120 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, |
| 121 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> | 121 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> |
| 122 saved_nigori_state) override {} | 122 saved_nigori_state) override {} |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 class SyncBackendHostMockCollectDeleteDirParam : public SyncBackendHostMock { | 125 class SyncBackendHostMockCollectDeleteDirParam : public SyncBackendHostMock { |
| 126 public: | 126 public: |
| 127 explicit SyncBackendHostMockCollectDeleteDirParam( | 127 explicit SyncBackendHostMockCollectDeleteDirParam( |
| 128 std::vector<bool>* delete_dir_param) | 128 std::vector<bool>* delete_dir_param) |
| 129 : delete_dir_param_(delete_dir_param) {} | 129 : delete_dir_param_(delete_dir_param) {} |
| 130 | 130 |
| 131 void Initialize( | 131 void Initialize( |
| 132 syncer::SyncFrontend* frontend, | 132 syncer::SyncFrontend* frontend, |
| 133 base::Thread* sync_thread, | 133 scoped_refptr<base::SingleThreadTaskRunner> sync_task_runner, |
| 134 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, | 134 const syncer::WeakHandle<syncer::JsEventHandler>& event_handler, |
| 135 const GURL& service_url, | 135 const GURL& service_url, |
| 136 const std::string& sync_user_agent, | 136 const std::string& sync_user_agent, |
| 137 const syncer::SyncCredentials& credentials, | 137 const syncer::SyncCredentials& credentials, |
| 138 bool delete_sync_data_folder, | 138 bool delete_sync_data_folder, |
| 139 bool enable_local_sync_backend, | 139 bool enable_local_sync_backend, |
| 140 const base::FilePath& local_sync_backend_folder, | 140 const base::FilePath& local_sync_backend_folder, |
| 141 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory, | 141 std::unique_ptr<syncer::SyncManagerFactory> sync_manager_factory, |
| 142 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& | 142 const syncer::WeakHandle<syncer::UnrecoverableErrorHandler>& |
| 143 unrecoverable_error_handler, | 143 unrecoverable_error_handler, |
| 144 const base::Closure& report_unrecoverable_error_function, | 144 const base::Closure& report_unrecoverable_error_function, |
| 145 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, | 145 const HttpPostProviderFactoryGetter& http_post_provider_factory_getter, |
| 146 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> | 146 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> |
| 147 saved_nigori_state) override { | 147 saved_nigori_state) override { |
| 148 delete_dir_param_->push_back(delete_sync_data_folder); | 148 delete_dir_param_->push_back(delete_sync_data_folder); |
| 149 SyncBackendHostMock::Initialize( | 149 SyncBackendHostMock::Initialize( |
| 150 frontend, sync_thread, event_handler, service_url, sync_user_agent, | 150 frontend, std::move(sync_task_runner), event_handler, service_url, |
| 151 credentials, delete_sync_data_folder, enable_local_sync_backend, | 151 sync_user_agent, credentials, delete_sync_data_folder, |
| 152 local_sync_backend_folder, std::move(sync_manager_factory), | 152 enable_local_sync_backend, local_sync_backend_folder, |
| 153 unrecoverable_error_handler, report_unrecoverable_error_function, | 153 std::move(sync_manager_factory), unrecoverable_error_handler, |
| 154 http_post_provider_factory_getter, std::move(saved_nigori_state)); | 154 report_unrecoverable_error_function, http_post_provider_factory_getter, |
| 155 std::move(saved_nigori_state)); |
| 155 } | 156 } |
| 156 | 157 |
| 157 private: | 158 private: |
| 158 std::vector<bool>* delete_dir_param_; | 159 std::vector<bool>* delete_dir_param_; |
| 159 }; | 160 }; |
| 160 | 161 |
| 161 // SyncBackendHostMock that calls an external callback when ClearServerData is | 162 // SyncBackendHostMock that calls an external callback when ClearServerData is |
| 162 // called. | 163 // called. |
| 163 class SyncBackendHostCaptureClearServerData : public SyncBackendHostMock { | 164 class SyncBackendHostCaptureClearServerData : public SyncBackendHostMock { |
| 164 public: | 165 public: |
| (...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 // Progress the controller to RUNNING first, which is how the service | 970 // Progress the controller to RUNNING first, which is how the service |
| 970 // determines whether a type is enabled. | 971 // determines whether a type is enabled. |
| 971 controller->StartAssociating(base::Bind(&DoNothing)); | 972 controller->StartAssociating(base::Bind(&DoNothing)); |
| 972 controller->FinishStart(DataTypeController::OK_FIRST_RUN); | 973 controller->FinishStart(DataTypeController::OK_FIRST_RUN); |
| 973 service()->RegisterDataTypeController(std::move(controller)); | 974 service()->RegisterDataTypeController(std::move(controller)); |
| 974 EXPECT_NE(nullptr, service()->GetOpenTabsUIDelegate()); | 975 EXPECT_NE(nullptr, service()->GetOpenTabsUIDelegate()); |
| 975 } | 976 } |
| 976 | 977 |
| 977 } // namespace | 978 } // namespace |
| 978 } // namespace browser_sync | 979 } // namespace browser_sync |
| OLD | NEW |