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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_settings_ui_wrapper.cc
diff --git a/chrome/browser/extensions/extension_settings_ui_wrapper.cc b/chrome/browser/extensions/extension_settings_ui_wrapper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fc60156cb2d5218fcd044bde6020914909e01dd2
--- /dev/null
+++ b/chrome/browser/extensions/extension_settings_ui_wrapper.cc
@@ -0,0 +1,99 @@
+// Copyright (c) 2011 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/extensions/extension_settings_ui_wrapper.h"
+
+#include "base/bind.h"
+#include "content/browser/browser_thread.h"
+
+ExtensionSettingsUIWrapper::ExtensionSettingsUIWrapper(
+ const FilePath& base_path)
+ : core_(new ExtensionSettingsUIWrapper::Core(base_path)) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+}
+
+void ExtensionSettingsUIWrapper::RunWithStorage(
+ const std::string& extension_id, const Callback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ BrowserThread::PostTask(
+ BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(
+ &ExtensionSettingsUIWrapper::Core::RunWithStorageOnFileThread,
+ core_.get(),
+ extension_id,
+ callback));
+}
+
+SyncableService* ExtensionSettingsUIWrapper::GetSyncableService() {
+ 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.
+}
+
+ExtensionSettingsUIWrapper::~ExtensionSettingsUIWrapper() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+}
+
+ExtensionSettingsUIWrapper::Core::Core(const FilePath& base_path)
+ : extension_settings_(NULL) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ BrowserThread::PostTask(
+ BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(
+ &ExtensionSettingsUIWrapper::Core::InitOnFileThread,
+ this,
+ base_path));
+}
+
+void ExtensionSettingsUIWrapper::Core::RunWithStorageOnFileThread(
+ const std::string& extension_id, const Callback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ DCHECK(extension_settings_);
+ callback.Run(extension_settings_->GetStorage(extension_id));
+}
+
+SyncDataList ExtensionSettingsUIWrapper::Core::GetAllSyncData(
+ syncable::ModelType type) const {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ DCHECK(extension_settings_);
+ return extension_settings_->GetAllSyncData(type);
+}
+
+SyncError ExtensionSettingsUIWrapper::Core::MergeDataAndStartSyncing(
+ syncable::ModelType type,
+ const SyncDataList& initial_sync_data,
+ SyncChangeProcessor* sync_processor) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ DCHECK(extension_settings_);
+ return extension_settings_->MergeDataAndStartSyncing(
+ type, initial_sync_data, sync_processor);
+}
+
+SyncError ExtensionSettingsUIWrapper::Core::ProcessSyncChanges(
+ const tracked_objects::Location& from_here,
+ const SyncChangeList& change_list) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ DCHECK(extension_settings_);
+ return extension_settings_->ProcessSyncChanges(from_here, change_list);
+}
+
+void ExtensionSettingsUIWrapper::Core::StopSyncing(syncable::ModelType type) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ DCHECK(extension_settings_);
+ extension_settings_->StopSyncing(type);
+}
+
+ExtensionSettingsUIWrapper::Core::~Core() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
+ BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ BrowserThread::DeleteSoon(
+ BrowserThread::FILE, FROM_HERE, extension_settings_);
+}
+
+void ExtensionSettingsUIWrapper::Core::InitOnFileThread(
+ const FilePath& base_path) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ DCHECK(!extension_settings_);
+ extension_settings_ = new ExtensionSettings(base_path);
+}

Powered by Google App Engine
This is Rietveld 408576698