Commit a7b64293 authored by zea@chromium.org's avatar zea@chromium.org

Move DataTypeManager into sync_driver component

BUG=339762

Review URL: https://codereview.chromium.org/278053002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269956 0039d316-1c4b-4281-b951-d872f2087c98
parent b072eceb
......@@ -23,7 +23,6 @@
#include "chrome/browser/sync/glue/bookmark_data_type_controller.h"
#include "chrome/browser/sync/glue/bookmark_model_associator.h"
#include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h"
#include "chrome/browser/sync/glue/data_type_manager_impl.h"
#include "chrome/browser/sync/glue/extension_data_type_controller.h"
#include "chrome/browser/sync/glue/extension_setting_data_type_controller.h"
#include "chrome/browser/sync/glue/password_data_type_controller.h"
......@@ -53,6 +52,7 @@
#include "components/dom_distiller/core/dom_distiller_service.h"
#include "components/password_manager/core/browser/password_store.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/sync_driver/data_type_manager_impl.h"
#include "components/sync_driver/data_type_manager_observer.h"
#include "components/sync_driver/generic_change_processor.h"
#include "components/sync_driver/proxy_data_type_controller.h"
......@@ -420,7 +420,8 @@ DataTypeManager* ProfileSyncComponentsFactoryImpl::CreateDataTypeManager(
SyncBackendHost* backend,
DataTypeManagerObserver* observer,
browser_sync::FailedDataTypesHandler* failed_data_types_handler) {
return new DataTypeManagerImpl(debug_info_listener,
return new DataTypeManagerImpl(base::Bind(ChromeReportUnrecoverableError),
debug_info_listener,
controllers,
encryption_handler,
backend,
......
......@@ -357,6 +357,7 @@ ACTION_P(MakeAutocompleteSyncComponents, wds) {
ACTION_P(ReturnNewDataTypeManagerWithDebugListener, debug_listener) {
return new browser_sync::DataTypeManagerImpl(
base::Closure(),
debug_listener,
arg1,
arg2,
......
......@@ -13,7 +13,6 @@
#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/glue/data_type_manager_impl.h"
#include "chrome/browser/sync/glue/sync_backend_host_mock.h"
#include "chrome/browser/sync/managed_user_signin_manager_wrapper.h"
#include "chrome/browser/sync/profile_sync_components_factory_mock.h"
......@@ -21,6 +20,7 @@
#include "chrome/test/base/testing_pref_service_syncable.h"
#include "chrome/test/base/testing_profile.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/sync_driver/data_type_manager_impl.h"
#include "components/sync_driver/pref_names.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "google_apis/gaia/gaia_constants.h"
......@@ -32,7 +32,8 @@ namespace browser_sync {
namespace {
ACTION(ReturnNewDataTypeManager) {
return new browser_sync::DataTypeManagerImpl(arg0,
return new browser_sync::DataTypeManagerImpl(base::Closure(),
arg0,
arg1,
arg2,
arg3,
......
......@@ -10,10 +10,10 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/sync/glue/data_type_manager_impl.h"
#include "chrome/browser/sync/glue/sync_backend_host_impl.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/sync_driver/data_type_manager_impl.h"
#include "components/sync_driver/sync_prefs.h"
#include "sync/test/engine/test_id_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
......@@ -24,7 +24,8 @@ class ProfileSyncComponentsFactory;
class ProfileSyncComponentsFactoryMock;
ACTION(ReturnNewDataTypeManager) {
return new browser_sync::DataTypeManagerImpl(arg0,
return new browser_sync::DataTypeManagerImpl(base::Closure(),
arg0,
arg1,
arg2,
arg3,
......
......@@ -2174,8 +2174,6 @@
'browser/sync/glue/browser_thread_model_worker.h',
'browser/sync/glue/chrome_report_unrecoverable_error.cc',
'browser/sync/glue/chrome_report_unrecoverable_error.h',
'browser/sync/glue/data_type_manager_impl.cc',
'browser/sync/glue/data_type_manager_impl.h',
'browser/sync/glue/device_info.cc',
'browser/sync/glue/device_info.h',
'browser/sync/glue/extension_data_type_controller.cc',
......
......@@ -1308,7 +1308,6 @@
'browser/sync/glue/autofill_data_type_controller_unittest.cc',
'browser/sync/glue/bookmark_data_type_controller_unittest.cc',
'browser/sync/glue/browser_thread_model_worker_unittest.cc',
'browser/sync/glue/data_type_manager_impl_unittest.cc',
'browser/sync/glue/extensions_activity_monitor_unittest.cc',
'browser/sync/glue/favicon_cache_unittest.cc',
'browser/sync/glue/frontend_data_type_controller_mock.cc',
......
......@@ -148,6 +148,7 @@
'storage_monitor/storage_monitor_mac_unittest.mm',
'storage_monitor/storage_monitor_unittest.cc',
'storage_monitor/storage_monitor_win_unittest.cc',
'sync_driver/data_type_manager_impl_unittest.cc',
'sync_driver/generic_change_processor_unittest.cc',
'sync_driver/model_association_manager_unittest.cc',
'sync_driver/non_blocking_data_type_controller_unittest.cc',
......
......@@ -27,6 +27,8 @@
'sync_driver/data_type_error_handler.h',
'sync_driver/data_type_manager.cc',
'sync_driver/data_type_manager.h',
'sync_driver/data_type_manager_impl.cc',
'sync_driver/data_type_manager_impl.h',
'sync_driver/data_type_manager_observer.h',
'sync_driver/failed_data_types_handler.cc',
'sync_driver/failed_data_types_handler.h',
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/sync/glue/data_type_manager_impl.h"
#include "components/sync_driver/data_type_manager_impl.h"
#include <algorithm>
#include <functional>
......@@ -16,16 +16,12 @@
#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h"
#include "components/sync_driver/data_type_controller.h"
#include "components/sync_driver/data_type_encryption_handler.h"
#include "components/sync_driver/data_type_manager_observer.h"
#include "components/sync_driver/failed_data_types_handler.h"
#include "content/public/browser/browser_thread.h"
#include "sync/internal_api/public/data_type_debug_info_listener.h"
using content::BrowserThread;
namespace browser_sync {
namespace {
......@@ -50,6 +46,7 @@ DataTypeManagerImpl::AssociationTypesInfo::AssociationTypesInfo() {}
DataTypeManagerImpl::AssociationTypesInfo::~AssociationTypesInfo() {}
DataTypeManagerImpl::DataTypeManagerImpl(
const base::Closure& unrecoverable_error_method,
const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
debug_info_listener,
const DataTypeController::TypeMap* controllers,
......@@ -67,6 +64,7 @@ DataTypeManagerImpl::DataTypeManagerImpl(
observer_(observer),
failed_data_types_handler_(failed_data_types_handler),
encryption_handler_(encryption_handler),
unrecoverable_error_method_(unrecoverable_error_method),
weak_ptr_factory_(this) {
DCHECK(failed_data_types_handler_);
DCHECK(configurer_);
......@@ -105,7 +103,6 @@ void DataTypeManagerImpl::PurgeForMigration(
void DataTypeManagerImpl::ConfigureImpl(
syncer::ModelTypeSet desired_types,
syncer::ConfigureReason reason) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_NE(reason, syncer::CONFIGURE_REASON_UNKNOWN);
DVLOG(1) << "Configuring for " << syncer::ModelTypeSetToString(desired_types)
<< " with reason " << reason;
......@@ -331,7 +328,8 @@ void DataTypeManagerImpl::DownloadReady(
}
if (!failed_configuration_types.Empty()) {
ChromeReportUnrecoverableError();
if (!unrecoverable_error_method_.is_null())
unrecoverable_error_method_.Run();
std::string error_msg =
"Configuration failed for types " +
syncer::ModelTypeSetToString(failed_configuration_types);
......@@ -494,7 +492,6 @@ void DataTypeManagerImpl::OnModelAssociationDone(
}
void DataTypeManagerImpl::Stop() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (state_ == STOPPED)
return;
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SYNC_GLUE_DATA_TYPE_MANAGER_IMPL_H__
#define CHROME_BROWSER_SYNC_GLUE_DATA_TYPE_MANAGER_IMPL_H__
#ifndef COMPONENTS_SYNC_DRIVER_DATA_TYPE_MANAGER_IMPL_H__
#define COMPONENTS_SYNC_DRIVER_DATA_TYPE_MANAGER_IMPL_H__
#include "components/sync_driver/data_type_manager.h"
......@@ -12,6 +12,7 @@
#include <vector>
#include "base/basictypes.h"
#include "base/callback_forward.h"
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
......@@ -39,6 +40,7 @@ class DataTypeManagerImpl : public DataTypeManager,
public ModelAssociationResultProcessor {
public:
DataTypeManagerImpl(
const base::Closure& unrecoverable_error_method,
const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
debug_info_listener,
const DataTypeController::TypeMap* controllers,
......@@ -184,6 +186,8 @@ class DataTypeManagerImpl : public DataTypeManager,
// Association and time stats of data type configuration.
std::vector<syncer::DataTypeConfigurationStats> configuration_stats_;
base::Closure unrecoverable_error_method_;
base::WeakPtrFactory<DataTypeManagerImpl> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(DataTypeManagerImpl);
......@@ -191,4 +195,4 @@ class DataTypeManagerImpl : public DataTypeManager,
} // namespace browser_sync
#endif // CHROME_BROWSER_SYNC_GLUE_DATA_TYPE_MANAGER_IMPL_H__
#endif // COMPONENTS_SYNC_DRIVER_DATA_TYPE_MANAGER_IMPL_H__
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/sync/glue/data_type_manager_impl.h"
#include "components/sync_driver/data_type_manager_impl.h"
#include "base/compiler_specific.h"
#include "base/message_loop/message_loop.h"
#include "chrome/browser/chrome_notification_types.h"
#include "components/sync_driver/backend_data_type_configurer.h"
#include "components/sync_driver/data_type_controller.h"
#include "components/sync_driver/data_type_encryption_handler.h"
#include "components/sync_driver/data_type_manager_observer.h"
#include "components/sync_driver/failed_data_types_handler.h"
#include "components/sync_driver/fake_data_type_controller.h"
#include "content/public/test/test_browser_thread.h"
#include "sync/internal_api/public/base/model_type.h"
#include "sync/internal_api/public/configure_reason.h"
#include "testing/gmock/include/gmock/gmock.h"
......@@ -148,7 +146,8 @@ class TestDataTypeManager : public DataTypeManagerImpl {
const DataTypeEncryptionHandler* encryption_handler,
DataTypeManagerObserver* observer,
FailedDataTypesHandler* failed_data_types_handler)
: DataTypeManagerImpl(debug_info_listener,
: DataTypeManagerImpl(base::Closure(),
debug_info_listener,
controllers,
encryption_handler,
configurer,
......@@ -183,8 +182,7 @@ class TestDataTypeManager : public DataTypeManagerImpl {
// run both configuring with nigori, and configuring without).
class SyncDataTypeManagerImplTest : public testing::Test {
public:
SyncDataTypeManagerImplTest()
: ui_thread_(content::BrowserThread::UI, &ui_loop_) {}
SyncDataTypeManagerImplTest() {}
virtual ~SyncDataTypeManagerImplTest() {
}
......@@ -253,7 +251,6 @@ class SyncDataTypeManagerImplTest : public testing::Test {
}
base::MessageLoopForUI ui_loop_;
content::TestBrowserThread ui_thread_;
DataTypeController::TypeMap controllers_;
FakeBackendDataTypeConfigurer configurer_;
DataTypeManagerObserverMock observer_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment