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

Unified Diff: chrome/browser/extensions/extension_settings_ui_wrapper.cc

Issue 7977018: Enable sync for the settings from the Extension Settings API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix race condition in ExtensionSettingsUIWrapper::Core 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..20cad1e35878ebc21c7b93e08bb3e610ab975e6f
--- /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()) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ BrowserThread::PostTask(
+ BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(
+ &ExtensionSettingsUIWrapper::Core::InitOnFileThread,
+ core_.get(),
+ base_path));
+}
+
+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()
+ : extension_settings_(NULL) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+}
+
+void ExtensionSettingsUIWrapper::Core::InitOnFileThread(
+ const FilePath& base_path) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ DCHECK(!extension_settings_);
+ extension_settings_ = new ExtensionSettings(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_);
+}

Powered by Google App Engine
This is Rietveld 408576698