OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 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/metrics/histogram.h" | |
8 #include "chrome/browser/extensions/extension_service.h" | |
9 #include "chrome/browser/extensions/extension_settings_ui_wrapper.h" | |
10 #include "chrome/browser/profiles/profile.h" | |
11 #include "chrome/browser/sync/api/syncable_service.h" | |
12 #include "chrome/browser/sync/glue/generic_change_processor.h" | |
13 #include "content/browser/browser_thread.h" | |
14 | |
15 namespace browser_sync { | |
16 | |
17 ExtensionSettingDataTypeController::ExtensionSettingDataTypeController( | |
18 ProfileSyncFactory* profile_sync_factory, | |
19 Profile* profile, | |
20 ProfileSyncService* profile_sync_service) | |
21 : NonFrontendDataTypeController(profile_sync_factory, profile), | |
22 extension_settings_ui_wrapper_( | |
23 profile->GetExtensionService()->extension_settings()), | |
24 extension_settings_(NULL), | |
25 profile_sync_service_(profile_sync_service) { | |
26 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
27 } | |
28 | |
29 ExtensionSettingDataTypeController::~ExtensionSettingDataTypeController() {} | |
30 | |
31 syncable::ModelType ExtensionSettingDataTypeController::type() const { | |
32 return syncable::EXTENSION_SETTINGS; | |
33 } | |
34 | |
35 browser_sync::ModelSafeGroup | |
36 ExtensionSettingDataTypeController::model_safe_group() const { | |
37 return browser_sync::GROUP_FILE; | |
38 } | |
39 | |
40 bool ExtensionSettingDataTypeController::StartModels() { | |
41 return true; | |
42 } | |
43 | |
44 bool ExtensionSettingDataTypeController::StartAssociationAsync() { | |
45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
46 DCHECK_EQ(state(), ASSOCIATING); | |
47 extension_settings_ui_wrapper_->RunWithSettings( | |
48 base::Bind( | |
49 &ExtensionSettingDataTypeController:: | |
50 StartAssociationWithExtensionSettings, | |
51 this)); | |
52 return true; | |
53 } | |
54 | |
55 void ExtensionSettingDataTypeController::StartAssociationWithExtensionSettings( | |
56 ExtensionSettings* extension_settings) { | |
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
58 extension_settings_ = extension_settings; | |
59 // Calls CreateSyncComponents. | |
akalin
2011/09/21 05:41:53
// Calls CreateSyncComponents, which expects exten
not at google - send to devlin
2011/09/21 06:22:41
Done.
| |
60 StartAssociation(); | |
61 } | |
62 | |
63 void ExtensionSettingDataTypeController::CreateSyncComponents() { | |
64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
65 DCHECK_EQ(state(), ASSOCIATING); | |
66 DCHECK(extension_settings_); | |
67 ProfileSyncFactory::SyncComponents sync_components = | |
68 profile_sync_factory()->CreateExtensionSettingSyncComponents( | |
69 extension_settings_, profile_sync_service_, this); | |
70 set_model_associator(sync_components.model_associator); | |
71 set_change_processor(sync_components.change_processor); | |
72 } | |
73 | |
74 bool ExtensionSettingDataTypeController::StopAssociationAsync() { | |
75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
76 DCHECK_EQ(state(), STOPPING); | |
77 if (!BrowserThread::PostTask( | |
78 BrowserThread::FILE, | |
79 FROM_HERE, | |
80 base::Bind( | |
81 &ExtensionSettingDataTypeController::StopAssociation, | |
82 this))) { | |
83 NOTREACHED(); | |
84 } | |
85 return true; | |
86 } | |
87 | |
88 void ExtensionSettingDataTypeController::RecordUnrecoverableError( | |
89 const tracked_objects::Location& from_here, | |
90 const std::string& message) { | |
91 UMA_HISTOGRAM_COUNTS("Sync.ExtensionSettingRunFailures", 1); | |
92 } | |
93 | |
94 void ExtensionSettingDataTypeController::RecordAssociationTime( | |
95 base::TimeDelta time) { | |
96 UMA_HISTOGRAM_TIMES("Sync.ExtensionSettingAssociationTime", time); | |
97 } | |
98 | |
99 void ExtensionSettingDataTypeController::RecordStartFailure( | |
100 StartResult result) { | |
101 UMA_HISTOGRAM_ENUMERATION( | |
102 "Sync.ExtensionSettingStartFailures", result, MAX_START_RESULT); | |
103 } | |
104 | |
105 } // namespace browser_sync | |
OLD | NEW |