| OLD | NEW |
| 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/sync/api/syncable_service.h" | 20 #include "chrome/browser/sync/api/syncable_service.h" |
| 20 | 21 |
| 21 class Profile; | 22 class Profile; |
| 22 | 23 |
| 23 namespace extensions { | 24 namespace extensions { |
| 24 | 25 |
| 25 class SettingsStorage; | 26 class SettingsStorage; |
| 26 | 27 |
| 27 // 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 |
| 28 // to SettingsBackend which lives on the FILE thread. | 29 // to SettingsBackend which lives on the FILE thread. |
| 29 // All public methods must be called on the UI thread. | 30 // All public methods must be called on the UI thread. |
| 30 class SettingsFrontend { | 31 class SettingsFrontend { |
| 31 public: | 32 public: |
| 32 // Creates with the default factory. Ownership of |profile| not taken. | 33 // Creates with the default factory. Ownership of |profile| not taken. |
| 33 static SettingsFrontend* Create(Profile* profile); | 34 static SettingsFrontend* Create(Profile* profile); |
| 34 | 35 |
| 36 // Creates with a specific factory |storage_factory| (presumably for tests). |
| 37 // Ownership of |profile| not taken. |
| 35 static SettingsFrontend* Create( | 38 static SettingsFrontend* Create( |
| 36 const scoped_refptr<SettingsStorageFactory>& storage_factory, | 39 const scoped_refptr<SettingsStorageFactory>& storage_factory, |
| 37 // Owership NOT taken. | 40 // Owership NOT taken. |
| 38 Profile* profile); | 41 Profile* profile); |
| 39 | 42 |
| 40 virtual ~SettingsFrontend(); | 43 virtual ~SettingsFrontend(); |
| 41 | 44 |
| 42 typedef base::Callback<void(SyncableService*)> SyncableServiceCallback; | 45 typedef base::Callback<void(SyncableService*)> SyncableServiceCallback; |
| 43 typedef base::Callback<void(SettingsStorage*)> StorageCallback; | 46 typedef base::Callback<void(SettingsStorage*)> StorageCallback; |
| 44 | 47 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 60 | 63 |
| 61 // Gets the thread-safe observer list. | 64 // Gets the thread-safe observer list. |
| 62 scoped_refptr<SettingsObserverList> GetObservers(); | 65 scoped_refptr<SettingsObserverList> GetObservers(); |
| 63 | 66 |
| 64 private: | 67 private: |
| 65 SettingsFrontend( | 68 SettingsFrontend( |
| 66 const scoped_refptr<SettingsStorageFactory>& storage_factory, | 69 const scoped_refptr<SettingsStorageFactory>& storage_factory, |
| 67 // Ownership NOT taken. | 70 // Ownership NOT taken. |
| 68 Profile* profile); | 71 Profile* profile); |
| 69 | 72 |
| 73 // The quota limit configurations for the local and sync areas, taken out of |
| 74 // the schema in chrome/common/extensions/api/storage.json. |
| 75 const SettingsStorageQuotaEnforcer::Limits local_quota_limit_; |
| 76 const SettingsStorageQuotaEnforcer::Limits sync_quota_limit_; |
| 77 |
| 70 // The (non-incognito) Profile this Frontend belongs to. | 78 // The (non-incognito) Profile this Frontend belongs to. |
| 71 Profile* const profile_; | 79 Profile* const profile_; |
| 72 | 80 |
| 73 // List of observers to settings changes. | 81 // List of observers to settings changes. |
| 74 scoped_refptr<SettingsObserverList> observers_; | 82 scoped_refptr<SettingsObserverList> observers_; |
| 75 | 83 |
| 76 // Observer for |profile_|. | 84 // Observer for |profile_|. |
| 77 scoped_ptr<SettingsObserver> profile_observer_; | 85 scoped_ptr<SettingsObserver> profile_observer_; |
| 78 | 86 |
| 79 // Ref-counted container for each SettingsBackend object. There are 4: an | 87 // Ref-counted container for each SettingsBackend object. There are 4: an |
| 80 // 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 |
| 81 // 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 |
| 82 // each exists in (and the Backends in the SYNC namespace happen to be | 90 // each exists in (and the Backends in the SYNC namespace happen to be |
| 83 // returned from RunWithSyncableService). | 91 // returned from RunWithSyncableService). |
| 84 class BackendWrapper; | 92 class BackendWrapper; |
| 85 struct BackendWrappers { | 93 struct BackendWrappers { |
| 86 BackendWrappers(); | 94 BackendWrappers(); |
| 87 ~BackendWrappers(); | 95 ~BackendWrappers(); |
| 88 scoped_refptr<BackendWrapper> app; | 96 scoped_refptr<BackendWrapper> app; |
| 89 scoped_refptr<BackendWrapper> extension; | 97 scoped_refptr<BackendWrapper> extension; |
| 90 }; | 98 }; |
| 91 std::map<settings_namespace::Namespace, BackendWrappers> backends_; | 99 std::map<settings_namespace::Namespace, BackendWrappers> backends_; |
| 92 | 100 |
| 93 DISALLOW_COPY_AND_ASSIGN(SettingsFrontend); | 101 DISALLOW_COPY_AND_ASSIGN(SettingsFrontend); |
| 94 }; | 102 }; |
| 95 | 103 |
| 96 } // namespace extensions | 104 } // namespace extensions |
| 97 | 105 |
| 98 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_FRONTEND_H_ | 106 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_FRONTEND_H_ |
| OLD | NEW |