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

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

Issue 8375047: Separate the syncing of extension settings and app settings into separate data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 1 month 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_FRONTEND_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_FRONTEND_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_FRONTEND_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_FRONTEND_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/observer_list_threadsafe.h" 13 #include "base/observer_list_threadsafe.h"
14 #include "chrome/browser/extensions/extension_settings_observer.h" 14 #include "chrome/browser/extensions/extension_settings_observer.h"
15 #include "chrome/browser/sync/api/syncable_service.h" 15 #include "chrome/browser/sync/api/syncable_service.h"
16 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
18 18
19 class FilePath; 19 class FilePath;
20 class Profile; 20 class Profile;
21 class ExtensionSettingsBackend;
22 class ExtensionSettingsStorage; 21 class ExtensionSettingsStorage;
23 22
24 // The component of extension settings which runs on the UI thread, as opposed 23 // The component of extension settings which runs on the UI thread, as opposed
25 // to ExtensionSettingsBackend which lives on the FILE thread. 24 // to ExtensionSettingsBackend which lives on the FILE thread.
26 class ExtensionSettingsFrontend : public content::NotificationObserver { 25 class ExtensionSettingsFrontend : public content::NotificationObserver {
27 public: 26 public:
28 explicit ExtensionSettingsFrontend(Profile* profile); 27 explicit ExtensionSettingsFrontend(Profile* profile);
29 virtual ~ExtensionSettingsFrontend(); 28 virtual ~ExtensionSettingsFrontend();
30 29
31 typedef base::Callback<void(ExtensionSettingsBackend*)> BackendCallback; 30 typedef base::Callback<void(SyncableService*)> SyncableServiceCallback;
31 typedef base::Callback<void(ExtensionSettingsStorage*)> StorageCallback;
32 32
33 // Runs |callback| on the FILE thread with the extension settings. 33 // Runs |callback| on the FILE thread with the SyncableService for
34 void RunWithBackend(const BackendCallback& callback); 34 // |model_type|, either EXTENSION_SETTINGS or APP_SETTINGS.
35 void RunWithSyncableService(
36 syncable::ModelType model_type, const SyncableServiceCallback& callback);
35 37
36 // Adds an observer to settings changes. 38 // Runs |callback| on the FILE thread with the storage area for
37 void AddObserver(ExtensionSettingsObserver* observer); 39 // |extension_id|. If there is no extension with that ID, the storage area
40 // will be NULL.
41 void RunWithStorage(
42 const std::string& extension_id, const StorageCallback& callback);
38 43
39 // Removes an observer to settings changes. 44 // Deletes the settings for an extension on the FILE thread. Must be called
40 void RemoveObserver(ExtensionSettingsObserver* observer); 45 // from the UI thread.
akalin 2011/10/28 06:04:54 The comment re. UI thread is correct, but it also
not at google - send to devlin 2011/10/31 00:02:23 Done.
46 void DeleteStorageSoon(const std::string& extension_id);
47
48 // Gets the thread-safe observer list.
49 scoped_refptr<ExtensionSettingsObserverList> GetObservers();
41 50
42 // NotificationObserver implementation. 51 // NotificationObserver implementation.
43 virtual void Observe( 52 virtual void Observe(
44 int type, 53 int type,
45 const content::NotificationSource& source, 54 const content::NotificationSource& source,
46 const content::NotificationDetails& details) OVERRIDE; 55 const content::NotificationDetails& details) OVERRIDE;
47 56
48 private: 57 private:
49 // Observer which sends events to a target profile iff the profile isn't the 58 // Observer which sends events to a target profile iff the profile isn't the
50 // originating profile for the event. 59 // originating profile for the event.
(...skipping 12 matching lines...) Expand all
63 // If a scoped DefaultObserver exists, clears it and removes it as an 72 // If a scoped DefaultObserver exists, clears it and removes it as an
64 // Observer. 73 // Observer.
65 void ClearDefaultObserver(scoped_ptr<DefaultObserver>* observer); 74 void ClearDefaultObserver(scoped_ptr<DefaultObserver>* observer);
66 75
67 // The (original) Profile this Frontend belongs to. Note that we don't store 76 // The (original) Profile this Frontend belongs to. Note that we don't store
68 // the incognito version of the profile because it will change as it's 77 // the incognito version of the profile because it will change as it's
69 // created and destroyed during the lifetime of Chrome. 78 // created and destroyed during the lifetime of Chrome.
70 Profile* const profile_; 79 Profile* const profile_;
71 80
72 // List of observers to settings changes. 81 // List of observers to settings changes.
73 scoped_refptr<ObserverListThreadSafe<ExtensionSettingsObserver> > observers_; 82 scoped_refptr<ExtensionSettingsObserverList> observers_;
74 83
75 // The default original and incognito mode profile observers. 84 // The default original and incognito mode profile observers.
76 scoped_ptr<DefaultObserver> original_profile_observer; 85 scoped_ptr<DefaultObserver> original_profile_observer;
77 scoped_ptr<DefaultObserver> incognito_profile_observer_; 86 scoped_ptr<DefaultObserver> incognito_profile_observer_;
78 87
79 // Ref-counted container for the ExtensionSettingsBackend object. 88 // Ref-counted container for the ExtensionSettingsBackend object.
80 class Core; 89 class Core;
81 scoped_refptr<Core> core_; 90 scoped_refptr<Core> core_;
82 91
83 // For profile created/destroyed notifications. 92 // For profile created/destroyed notifications.
84 content::NotificationRegistrar registrar_; 93 content::NotificationRegistrar registrar_;
85 94
86 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsFrontend); 95 DISALLOW_COPY_AND_ASSIGN(ExtensionSettingsFrontend);
87 }; 96 };
88 97
89 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_FRONTEND_H_ 98 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SETTINGS_FRONTEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698