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

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

Issue 10662035: [Sync] Put everything in sync/api into csync namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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_BACKEND_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_
6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_ 6 #define CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/memory/linked_ptr.h" 11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/observer_list_threadsafe.h" 13 #include "base/observer_list_threadsafe.h"
14 #include "chrome/browser/extensions/settings/settings_observer.h" 14 #include "chrome/browser/extensions/settings/settings_observer.h"
15 #include "chrome/browser/extensions/settings/settings_storage_factory.h" 15 #include "chrome/browser/extensions/settings/settings_storage_factory.h"
16 #include "chrome/browser/extensions/settings/settings_storage_quota_enforcer.h" 16 #include "chrome/browser/extensions/settings/settings_storage_quota_enforcer.h"
17 #include "chrome/browser/extensions/settings/syncable_settings_storage.h" 17 #include "chrome/browser/extensions/settings/syncable_settings_storage.h"
18 #include "chrome/browser/value_store/leveldb_value_store.h" 18 #include "chrome/browser/value_store/leveldb_value_store.h"
19 #include "sync/api/syncable_service.h" 19 #include "sync/api/syncable_service.h"
20 20
21 namespace csync {
21 class SyncErrorFactory; 22 class SyncErrorFactory;
23 }
22 24
23 namespace extensions { 25 namespace extensions {
24 26
25 // Manages ValueStore objects for extensions, including routing 27 // Manages ValueStore objects for extensions, including routing
26 // changes from sync to them. 28 // changes from sync to them.
27 // Lives entirely on the FILE thread. 29 // Lives entirely on the FILE thread.
28 class SettingsBackend : public SyncableService { 30 class SettingsBackend : public csync::SyncableService {
29 public: 31 public:
30 // |storage_factory| is use to create leveldb storage areas. 32 // |storage_factory| is use to create leveldb storage areas.
31 // |base_path| is the base of the extension settings directory, so the 33 // |base_path| is the base of the extension settings directory, so the
32 // databases will be at base_path/extension_id. 34 // databases will be at base_path/extension_id.
33 // |observers| is the list of observers to settings changes. 35 // |observers| is the list of observers to settings changes.
34 SettingsBackend( 36 SettingsBackend(
35 const scoped_refptr<SettingsStorageFactory>& storage_factory, 37 const scoped_refptr<SettingsStorageFactory>& storage_factory,
36 const FilePath& base_path, 38 const FilePath& base_path,
37 const SettingsStorageQuotaEnforcer::Limits& quota, 39 const SettingsStorageQuotaEnforcer::Limits& quota,
38 const scoped_refptr<SettingsObserverList>& observers); 40 const scoped_refptr<SettingsObserverList>& observers);
39 41
40 virtual ~SettingsBackend(); 42 virtual ~SettingsBackend();
41 43
42 // Gets a weak reference to the storage area for |extension_id|. 44 // Gets a weak reference to the storage area for |extension_id|.
43 // Must be run on the FILE thread. 45 // Must be run on the FILE thread.
44 ValueStore* GetStorage(const std::string& extension_id) const; 46 ValueStore* GetStorage(const std::string& extension_id) const;
45 47
46 // Deletes all setting data for an extension. Call on the FILE thread. 48 // Deletes all setting data for an extension. Call on the FILE thread.
47 void DeleteStorage(const std::string& extension_id); 49 void DeleteStorage(const std::string& extension_id);
48 50
49 // SyncableService implementation. 51 // csync::SyncableService implementation.
50 virtual SyncDataList GetAllSyncData(syncable::ModelType type) const OVERRIDE; 52 virtual csync::SyncDataList GetAllSyncData(
51 virtual SyncError MergeDataAndStartSyncing( 53 syncable::ModelType type) const OVERRIDE;
54 virtual csync::SyncError MergeDataAndStartSyncing(
52 syncable::ModelType type, 55 syncable::ModelType type,
53 const SyncDataList& initial_sync_data, 56 const csync::SyncDataList& initial_sync_data,
54 scoped_ptr<SyncChangeProcessor> sync_processor, 57 scoped_ptr<csync::SyncChangeProcessor> sync_processor,
55 scoped_ptr<SyncErrorFactory> sync_error_factory) OVERRIDE; 58 scoped_ptr<csync::SyncErrorFactory> sync_error_factory) OVERRIDE;
56 virtual SyncError ProcessSyncChanges( 59 virtual csync::SyncError ProcessSyncChanges(
57 const tracked_objects::Location& from_here, 60 const tracked_objects::Location& from_here,
58 const SyncChangeList& change_list) OVERRIDE; 61 const csync::SyncChangeList& change_list) OVERRIDE;
59 virtual void StopSyncing(syncable::ModelType type) OVERRIDE; 62 virtual void StopSyncing(syncable::ModelType type) OVERRIDE;
60 63
61 private: 64 private:
62 // Gets a weak reference to the storage area for a given extension, 65 // Gets a weak reference to the storage area for a given extension,
63 // initializing sync with some initial data if sync enabled. 66 // initializing sync with some initial data if sync enabled.
64 SyncableSettingsStorage* GetOrCreateStorageWithSyncData( 67 SyncableSettingsStorage* GetOrCreateStorageWithSyncData(
65 const std::string& extension_id, 68 const std::string& extension_id,
66 const DictionaryValue& sync_data) const; 69 const DictionaryValue& sync_data) const;
67 70
68 // Gets all extension IDs known to extension settings. This may not be all 71 // Gets all extension IDs known to extension settings. This may not be all
(...skipping 20 matching lines...) Expand all
89 // Ensure that there is only ever one created per extension. 92 // Ensure that there is only ever one created per extension.
90 typedef std::map<std::string, linked_ptr<SyncableSettingsStorage> > 93 typedef std::map<std::string, linked_ptr<SyncableSettingsStorage> >
91 StorageObjMap; 94 StorageObjMap;
92 mutable StorageObjMap storage_objs_; 95 mutable StorageObjMap storage_objs_;
93 96
94 // Current sync model type. Will be UNSPECIFIED if sync hasn't been enabled 97 // Current sync model type. Will be UNSPECIFIED if sync hasn't been enabled
95 // yet, and either SETTINGS or APP_SETTINGS if it has been. 98 // yet, and either SETTINGS or APP_SETTINGS if it has been.
96 syncable::ModelType sync_type_; 99 syncable::ModelType sync_type_;
97 100
98 // Current sync processor, if any. 101 // Current sync processor, if any.
99 scoped_ptr<SyncChangeProcessor> sync_processor_; 102 scoped_ptr<csync::SyncChangeProcessor> sync_processor_;
100 103
101 // Current sync error handler if any. 104 // Current sync error handler if any.
102 scoped_ptr<SyncErrorFactory> sync_error_factory_; 105 scoped_ptr<csync::SyncErrorFactory> sync_error_factory_;
103 106
104 DISALLOW_COPY_AND_ASSIGN(SettingsBackend); 107 DISALLOW_COPY_AND_ASSIGN(SettingsBackend);
105 }; 108 };
106 109
107 } // namespace extensions 110 } // namespace extensions
108 111
109 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_ 112 #endif // CHROME_BROWSER_EXTENSIONS_SETTINGS_SETTINGS_BACKEND_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698