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); |
+} |