Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(604)

Side by Side Diff: chrome/browser/extensions/extension_settings_ui_wrapper.cc

Issue 7775008: Enable sync for the settings from the Extension Settings API. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Comments, GCC compile fix Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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/extensions/extension_settings_ui_wrapper.h"
6
7 #include "base/bind.h"
8 #include "content/browser/browser_thread.h"
9
10 ExtensionSettingsUIWrapper::ExtensionSettingsUIWrapper(
11 const FilePath& base_path)
12 : core_(new ExtensionSettingsUIWrapper::Core(base_path)) {
13 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
14 }
15
16 void ExtensionSettingsUIWrapper::RunWithStorage(
17 const std::string& extension_id, const Callback& callback) {
18 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
19 BrowserThread::PostTask(
20 BrowserThread::FILE,
21 FROM_HERE,
22 base::Bind(
23 &ExtensionSettingsUIWrapper::Core::RunWithStorageOnFileThread,
24 core_.get(),
25 extension_id,
26 callback));
27 }
28
29 SyncableService* ExtensionSettingsUIWrapper::GetSyncableService() {
30 return core_.get();
akalin 2011/09/20 14:53:11 DCHECK ui thread
not at google - send to devlin 2011/09/21 00:20:14 Done.
not at google - send to devlin 2011/09/21 01:44:00 Actually this can't work that way it's structured.
31 }
32
33 ExtensionSettingsUIWrapper::~ExtensionSettingsUIWrapper() {
34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
35 }
36
37 ExtensionSettingsUIWrapper::Core::Core(const FilePath& base_path)
38 : extension_settings_(NULL) {
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
40 BrowserThread::PostTask(
41 BrowserThread::FILE,
42 FROM_HERE,
43 base::Bind(
44 &ExtensionSettingsUIWrapper::Core::InitOnFileThread,
45 this,
46 base_path));
47 }
48
49 void ExtensionSettingsUIWrapper::Core::RunWithStorageOnFileThread(
50 const std::string& extension_id, const Callback& callback) {
51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
52 DCHECK(extension_settings_);
53 callback.Run(extension_settings_->GetStorage(extension_id));
54 }
55
56 SyncDataList ExtensionSettingsUIWrapper::Core::GetAllSyncData(
57 syncable::ModelType type) const {
58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
59 DCHECK(extension_settings_);
60 return extension_settings_->GetAllSyncData(type);
61 }
62
63 SyncError ExtensionSettingsUIWrapper::Core::MergeDataAndStartSyncing(
64 syncable::ModelType type,
65 const SyncDataList& initial_sync_data,
66 SyncChangeProcessor* sync_processor) {
67 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
68 DCHECK(extension_settings_);
69 return extension_settings_->MergeDataAndStartSyncing(
70 type, initial_sync_data, sync_processor);
71 }
72
73 SyncError ExtensionSettingsUIWrapper::Core::ProcessSyncChanges(
74 const tracked_objects::Location& from_here,
75 const SyncChangeList& change_list) {
76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
77 DCHECK(extension_settings_);
78 return extension_settings_->ProcessSyncChanges(from_here, change_list);
79 }
80
81 void ExtensionSettingsUIWrapper::Core::StopSyncing(syncable::ModelType type) {
82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
83 DCHECK(extension_settings_);
84 extension_settings_->StopSyncing(type);
85 }
86
87 ExtensionSettingsUIWrapper::Core::~Core() {
88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
89 BrowserThread::CurrentlyOn(BrowserThread::FILE));
90 BrowserThread::DeleteSoon(
91 BrowserThread::FILE, FROM_HERE, extension_settings_);
92 }
93
94 void ExtensionSettingsUIWrapper::Core::InitOnFileThread(
95 const FilePath& base_path) {
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
97 DCHECK(!extension_settings_);
98 extension_settings_ = new ExtensionSettings(base_path);
99 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698