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

Side by Side Diff: chrome/browser/extensions/extension_settings_ui_wrapper.h

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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_UI_WRAPPER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_UI_WRAPPER_H_
7 #pragma once
8
9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/callback.h"
12 #include "chrome/browser/sync/api/syncable_service.h"
13
14 class FilePath;
15 class ExtensionSettings;
16 class ExtensionSettingsStorage;
17
18 // Wrapper for an ExtensionSettings object for dealing with thread ownership.
19 // This class lives on the UI thread while ExtensionSettings object live on
20 // the FILE thread.
21 class ExtensionSettingsUIWrapper {
22 public:
23 explicit ExtensionSettingsUIWrapper(const FilePath& base_path);
24
25 typedef base::Callback<void(ExtensionSettings*)> SettingsCallback;
26
27 // Runs |callback| on the FILE thread with the extension settings.
28 void RunWithSettings(const SettingsCallback& callback);
29
30 ~ExtensionSettingsUIWrapper();
31
32 private:
33 // Ref-counted container for the ExtensionSettings object.
34 class Core : public base::RefCountedThreadSafe<Core> {
35 public:
36 // Constructed on UI thread.
37 Core();
38
39 // Does any FILE thread specific initialization, such as
40 // construction of |extension_settings_|. Must be called before
41 // any call to RunWithSettingsOnFileThread().
42 void InitOnFileThread(const FilePath& base_path);
43
44 // Runs |callback| with extension settings.
45 void RunWithSettingsOnFileThread(const SettingsCallback& callback);
46
47 private:
48 // Can be destroyed on either the UI or FILE thread.
49 virtual ~Core();
50 friend class base::RefCountedThreadSafe<Core>;
51
52 // Lives on the FILE thread.
53 ExtensionSettings* extension_settings_;
54
55 DISALLOW_COPY_AND_ASSIGN(Core);
56 };
57
58 scoped_refptr<Core> core_;
59
60 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsUIWrapper);
61 };
62
63 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_UI_WRAPPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_settings_sync_util.cc ('k') | chrome/browser/extensions/extension_settings_ui_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698