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

Side by Side Diff: chrome/browser/extensions/settings/settings_frontend.h

Issue 9414020: [Sync] Switch Extension Settings DTC to use ProfilesyncComponentsFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DCHECK Created 8 years, 10 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_SETTINGS_SETTINGS_FRONTEND_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_FRONTEND_H_
6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_FRONTEND_H_ 6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_FRONTEND_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/observer_list_threadsafe.h" 15 #include "base/observer_list_threadsafe.h"
16 #include "chrome/browser/extensions/settings/settings_leveldb_storage.h" 16 #include "chrome/browser/extensions/settings/settings_leveldb_storage.h"
17 #include "chrome/browser/extensions/settings/settings_namespace.h" 17 #include "chrome/browser/extensions/settings/settings_namespace.h"
18 #include "chrome/browser/extensions/settings/settings_observer.h" 18 #include "chrome/browser/extensions/settings/settings_observer.h"
19 #include "chrome/browser/extensions/settings/settings_storage_quota_enforcer.h" 19 #include "chrome/browser/extensions/settings/settings_storage_quota_enforcer.h"
20 #include "chrome/browser/sync/api/syncable_service.h" 20 #include "chrome/browser/sync/api/syncable_service.h"
21 21
22 class Profile; 22 class Profile;
23 23
24 namespace extensions { 24 namespace extensions {
25 25
26 class SettingsStorage; 26 class SettingsStorage;
27 27
28 // The component of extension settings which runs on the UI thread, as opposed 28 // The component of extension settings which runs on the UI thread, as opposed
29 // to SettingsBackend which lives on the FILE thread. 29 // to SettingsBackend which lives on the FILE thread.
30 // All public methods must be called on the UI thread. 30 // All public methods, must be called on the UI thread, with the exception of
31 // GetBackendForSync(), which must be called on the FILE thread.
31 class SettingsFrontend { 32 class SettingsFrontend {
32 public: 33 public:
33 // Creates with the default factory. Ownership of |profile| not taken. 34 // Creates with the default factory. Ownership of |profile| not taken.
34 static SettingsFrontend* Create(Profile* profile); 35 static SettingsFrontend* Create(Profile* profile);
35 36
36 // Creates with a specific factory |storage_factory| (presumably for tests). 37 // Creates with a specific factory |storage_factory| (presumably for tests).
37 // Ownership of |profile| not taken. 38 // Ownership of |profile| not taken.
38 static SettingsFrontend* Create( 39 static SettingsFrontend* Create(
39 const scoped_refptr<SettingsStorageFactory>& storage_factory, 40 const scoped_refptr<SettingsStorageFactory>& storage_factory,
40 // Owership NOT taken. 41 // Owership NOT taken.
41 Profile* profile); 42 Profile* profile);
42 43
43 virtual ~SettingsFrontend(); 44 virtual ~SettingsFrontend();
44 45
45 typedef base::Callback<void(SyncableService*)> SyncableServiceCallback; 46 typedef base::Callback<void(SyncableService*)> SyncableServiceCallback;
46 typedef base::Callback<void(SettingsStorage*)> StorageCallback; 47 typedef base::Callback<void(SettingsStorage*)> StorageCallback;
47 48
48 // Runs |callback| on the FILE thread with the SyncableService for 49 // Must only be called from the FILE thread. |type| should be either
49 // |model_type|, either EXTENSION_SETTINGS or APP_SETTINGS. 50 // APP_SETTINGS or EXTENSION_SETTINGS.
50 void RunWithSyncableService( 51 SyncableService* GetBackendForSync(syncable::ModelType type) const;
51 syncable::ModelType model_type, const SyncableServiceCallback& callback);
52 52
53 // Runs |callback| on the FILE thread with the storage area for 53 // Runs |callback| on the FILE thread with the storage area for
54 // |extension_id|. If there is no extension with that ID, the storage area 54 // |extension_id|. If there is no extension with that ID, the storage area
55 // will be NULL. 55 // will be NULL.
56 void RunWithStorage( 56 void RunWithStorage(
57 const std::string& extension_id, 57 const std::string& extension_id,
58 settings_namespace::Namespace settings_namespace, 58 settings_namespace::Namespace settings_namespace,
59 const StorageCallback& callback); 59 const StorageCallback& callback);
60 60
61 // Deletes the settings for an extension (on the FILE thread). 61 // Deletes the settings for an extension (on the FILE thread).
(...skipping 18 matching lines...) Expand all
80 80
81 // List of observers to settings changes. 81 // List of observers to settings changes.
82 scoped_refptr<SettingsObserverList> observers_; 82 scoped_refptr<SettingsObserverList> observers_;
83 83
84 // Observer for |profile_|. 84 // Observer for |profile_|.
85 scoped_ptr<SettingsObserver> profile_observer_; 85 scoped_ptr<SettingsObserver> profile_observer_;
86 86
87 // Ref-counted container for each SettingsBackend object. There are 4: an 87 // Ref-counted container for each SettingsBackend object. There are 4: an
88 // apps and an extensions Backend for the LOCAL namespace, and likewise for 88 // apps and an extensions Backend for the LOCAL namespace, and likewise for
89 // the SYNC namespace. They only differ in what directory the database for 89 // the SYNC namespace. They only differ in what directory the database for
90 // each exists in (and the Backends in the SYNC namespace happen to be 90 // each exists in.
91 // returned from RunWithSyncableService).
92 class BackendWrapper; 91 class BackendWrapper;
93 struct BackendWrappers { 92 struct BackendWrappers {
94 BackendWrappers(); 93 BackendWrappers();
95 ~BackendWrappers(); 94 ~BackendWrappers();
96 scoped_refptr<BackendWrapper> app; 95 scoped_refptr<BackendWrapper> app;
97 scoped_refptr<BackendWrapper> extension; 96 scoped_refptr<BackendWrapper> extension;
98 }; 97 };
99 std::map<settings_namespace::Namespace, BackendWrappers> backends_; 98 std::map<settings_namespace::Namespace, BackendWrappers> backends_;
100 99
101 DISALLOW_COPY_AND_ASSIGN(SettingsFrontend); 100 DISALLOW_COPY_AND_ASSIGN(SettingsFrontend);
102 }; 101 };
103 102
104 } // namespace extensions 103 } // namespace extensions
105 104
106 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_FRONTEND_H_ 105 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_FRONTEND_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/settings/settings_apitest.cc ('k') | chrome/browser/extensions/settings/settings_frontend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698