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

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

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.h
diff --git a/chrome/browser/extensions/extension_settings_ui_wrapper.h b/chrome/browser/extensions/extension_settings_ui_wrapper.h
new file mode 100644
index 0000000000000000000000000000000000000000..664bb14d9ebecd2df3bf30a6cf2c97e30d7063f3
--- /dev/null
+++ b/chrome/browser/extensions/extension_settings_ui_wrapper.h
@@ -0,0 +1,62 @@
+// 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.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_UI_WRAPPER_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_UI_WRAPPER_H_
+#pragma once
+
+#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
+#include "base/callback.h"
+#include "chrome/browser/sync/api/syncable_service.h"
+
+class FilePath;
+class ExtensionSettings;
+class ExtensionSettingsStorage;
+
+// Wrapper for an ExtensionSettings object for dealing with thread ownership.
+// This class lives on the UI thread while ExtensionSettings object live on
+// the FILE thread.
+class ExtensionSettingsUIWrapper {
+ public:
+ explicit ExtensionSettingsUIWrapper(const FilePath& base_path);
+
+ typedef base::Callback<void(ExtensionSettings*)> SettingsCallback;
+
+ // Runs |callback| on the FILE thread with the extension settings.
+ void RunWithSettings(const SettingsCallback& callback);
+
+ ~ExtensionSettingsUIWrapper();
+
+ private:
+ // Ref-counted container for the ExtensionSettings object.
+ class Core : public base::RefCountedThreadSafe<Core> {
+ public:
+ // Constructed on UI thread.
+ explicit Core(const FilePath& base_path);
+
+ // Runs |callback| with extension settings.
+ void RunWithSettingsOnFileThread(const SettingsCallback& callback);
+
+ private:
+ // Can be destroyed on either the UI or FILE thread.
+ virtual ~Core();
+ friend class base::RefCountedThreadSafe<Core>;
+
+ // Does any FILE thread specific initialization, such as construction of
+ // |extension_settings_|.
+ void InitOnFileThread(const FilePath& base_path);
+
+ // Lives on the FILE thread.
+ ExtensionSettings* extension_settings_;
+
+ DISALLOW_COPY_AND_ASSIGN(Core);
+ };
+
+ scoped_refptr<Core> core_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsUIWrapper);
+};
+
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_UI_WRAPPER_H_

Powered by Google App Engine
This is Rietveld 408576698