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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sync/glue/extension_setting_data_type_controller.h"
6
7 #include "base/bind.h"
8 #include "base/metrics/histogram.h"
9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h"
12 #include "chrome/browser/sync/profile_sync_components_factory.h"
13 #include "components/sync_driver/generic_change_processor.h"
14 #include "content/public/browser/browser_thread.h"
15 #include "extensions/browser/extension_system.h"
16 #include "sync/api/syncable_service.h"
17
18 using content::BrowserThread;
19
20 namespace browser_sync {
21
ExtensionSettingDataTypeController(syncer::ModelType type,ProfileSyncComponentsFactory * profile_sync_factory,Profile * profile)22 ExtensionSettingDataTypeController::ExtensionSettingDataTypeController(
23 syncer::ModelType type,
24 ProfileSyncComponentsFactory* profile_sync_factory,
25 Profile* profile)
26 : NonUIDataTypeController(
27 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
28 base::Bind(&ChromeReportUnrecoverableError),
29 profile_sync_factory),
30 type_(type),
31 profile_(profile) {
32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
33 DCHECK(type == syncer::EXTENSION_SETTINGS || type == syncer::APP_SETTINGS);
34 }
35
type() const36 syncer::ModelType ExtensionSettingDataTypeController::type() const {
37 return type_;
38 }
39
40 syncer::ModelSafeGroup
model_safe_group() const41 ExtensionSettingDataTypeController::model_safe_group() const {
42 return syncer::GROUP_FILE;
43 }
44
~ExtensionSettingDataTypeController()45 ExtensionSettingDataTypeController::~ExtensionSettingDataTypeController() {}
46
PostTaskOnBackendThread(const tracked_objects::Location & from_here,const base::Closure & task)47 bool ExtensionSettingDataTypeController::PostTaskOnBackendThread(
48 const tracked_objects::Location& from_here,
49 const base::Closure& task) {
50 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
51 return BrowserThread::PostTask(BrowserThread::FILE, from_here, task);
52 }
53
StartModels()54 bool ExtensionSettingDataTypeController::StartModels() {
55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
56 extensions::ExtensionSystem::Get(profile_)->InitForRegularProfile(true);
57 return true;
58 }
59
60 } // namespace browser_sync
61