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

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: Review #6 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..567c5bf5aadb67b9a434492eafc83774f4d26228
--- /dev/null
+++ b/chrome/browser/extensions/extension_settings_ui_wrapper.cc
@@ -0,0 +1,65 @@
+// 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 "base/file_path.h"
+#include "chrome/browser/extensions/extension_settings.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::RunWithSettings(
+ const SettingsCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ BrowserThread::PostTask(
+ BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(
+ &ExtensionSettingsUIWrapper::Core::RunWithSettingsOnFileThread,
+ core_.get(),
+ callback));
+}
+
+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::RunWithSettingsOnFileThread(
+ const SettingsCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ DCHECK(extension_settings_);
+ callback.Run(extension_settings_);
+}
+
+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