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

Side by Side 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 #5 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(ExtensionSettingsStorage*)> StorageCallback;
26
27 // Runs |callback| on the FILE thread with the storage area for the extension
28 // with ID |extension_id|.
29 void RunWithStorage(
30 const std::string& extension_id, const StorageCallback& callback);
31
32 // Gets the SyncableService component of the ExtensionSettings. The service
akalin 2011/09/21 01:58:41 remove this, and instead have: void RunWithExtens
not at google - send to devlin 2011/09/21 03:55:18 This should make RunWithStorage unnecessary, right
akalin 2011/09/21 05:41:53 Yeah, that's true. Cool.
33 // itself lives on the FILE thread. Needed for ProfileSyncFactory.
34 SyncableService* GetSyncableService();
35
36 ~ExtensionSettingsUIWrapper();
37
38 private:
39 // Ref-counted container for the ExtensionSettings object. Delegates
40 // SyncableService calls.
41 class Core : public base::RefCountedThreadSafe<Core>, public SyncableService {
akalin 2011/09/21 01:58:41 no need to have this be a syncableservice anymore
not at google - send to devlin 2011/09/21 03:55:18 Done.
42 public:
43 // Constructed on UI thread.
44 explicit Core(const FilePath& base_path);
45
46 // Runs |callback| with the storage area for the extension with ID
47 // |extension_id|. Must be run on the FILE thread.
48 void RunWithStorageOnFileThread(
49 const std::string& extension_id, const StorageCallback& callback);
50
51 // SyncableService implementation (just delegates to |extension_settings_|).
52 // All run on the FILE thread.
53 // Note that when any of these methods are called, |extension_settings_| is
54 // guaranteed to have already been created, since |extension_settings_| is
55 // constructed on the FILE thread.
56 virtual SyncDataList GetAllSyncData(
57 syncable::ModelType type) const OVERRIDE;
58 virtual SyncError MergeDataAndStartSyncing(
59 syncable::ModelType type,
60 const SyncDataList& initial_sync_data,
61 SyncChangeProcessor* sync_processor) OVERRIDE;
62 virtual SyncError ProcessSyncChanges(
63 const tracked_objects::Location& from_here,
64 const SyncChangeList& change_list) OVERRIDE;
65 virtual void StopSyncing(syncable::ModelType type) OVERRIDE;
66
67 private:
68 // Can be destroyed on either the UI or FILE thread.
69 virtual ~Core();
70 friend class base::RefCountedThreadSafe<Core>;
71
72 // Does any FILE thread specific initialization, such as construction of
73 // |extension_settings_|.
74 void InitOnFileThread(const FilePath& base_path);
75
76 // Lives on the FILE thread.
77 ExtensionSettings* extension_settings_;
78
79 DISALLOW_COPY_AND_ASSIGN(Core);
80 };
81
82 scoped_refptr<Core> core_;
83
84 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsUIWrapper);
85 };
86
87 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_UI_WRAPPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698