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_API_STORAGE_SYNCABLE_SETTINGS_STORAGE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNCABLE_SETTINGS_STORAGE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNCABLE_SETTINGS_STORAGE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNCABLE_SETTINGS_STORAGE_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 virtual size_t GetBytesInUse(const std::vector<std::string>& keys) OVERRIDE; | 36 virtual size_t GetBytesInUse(const std::vector<std::string>& keys) OVERRIDE; |
37 virtual size_t GetBytesInUse() OVERRIDE; | 37 virtual size_t GetBytesInUse() OVERRIDE; |
38 virtual ReadResult Get(const std::string& key) OVERRIDE; | 38 virtual ReadResult Get(const std::string& key) OVERRIDE; |
39 virtual ReadResult Get(const std::vector<std::string>& keys) OVERRIDE; | 39 virtual ReadResult Get(const std::vector<std::string>& keys) OVERRIDE; |
40 virtual ReadResult Get() OVERRIDE; | 40 virtual ReadResult Get() OVERRIDE; |
41 virtual WriteResult Set( | 41 virtual WriteResult Set( |
42 WriteOptions options, | 42 WriteOptions options, |
43 const std::string& key, | 43 const std::string& key, |
44 const Value& value) OVERRIDE; | 44 const Value& value) OVERRIDE; |
45 virtual WriteResult Set( | 45 virtual WriteResult Set( |
46 WriteOptions options, const DictionaryValue& values) OVERRIDE; | 46 WriteOptions options, const base::DictionaryValue& values) OVERRIDE; |
47 virtual WriteResult Remove(const std::string& key) OVERRIDE; | 47 virtual WriteResult Remove(const std::string& key) OVERRIDE; |
48 virtual WriteResult Remove(const std::vector<std::string>& keys) OVERRIDE; | 48 virtual WriteResult Remove(const std::vector<std::string>& keys) OVERRIDE; |
49 virtual WriteResult Clear() OVERRIDE; | 49 virtual WriteResult Clear() OVERRIDE; |
50 | 50 |
51 // Sync-related methods, analogous to those on SyncableService (handled by | 51 // Sync-related methods, analogous to those on SyncableService (handled by |
52 // ExtensionSettings), but with looser guarantees about when the methods | 52 // ExtensionSettings), but with looser guarantees about when the methods |
53 // can be called. | 53 // can be called. |
54 | 54 |
55 // Must only be called if sync isn't already active. | 55 // Must only be called if sync isn't already active. |
56 syncer::SyncError StartSyncing( | 56 syncer::SyncError StartSyncing( |
57 const DictionaryValue& sync_state, | 57 const base::DictionaryValue& sync_state, |
58 scoped_ptr<SettingsSyncProcessor> sync_processor); | 58 scoped_ptr<SettingsSyncProcessor> sync_processor); |
59 | 59 |
60 // May be called at any time (idempotent). | 60 // May be called at any time (idempotent). |
61 void StopSyncing(); | 61 void StopSyncing(); |
62 | 62 |
63 // May be called at any time; changes will be ignored if sync isn't active. | 63 // May be called at any time; changes will be ignored if sync isn't active. |
64 syncer::SyncError ProcessSyncChanges(const SettingSyncDataList& sync_changes); | 64 syncer::SyncError ProcessSyncChanges(const SettingSyncDataList& sync_changes); |
65 | 65 |
66 private: | 66 private: |
67 // Sends the changes from |result| to sync if it's enabled. | 67 // Sends the changes from |result| to sync if it's enabled. |
68 void SyncResultIfEnabled(const ValueStore::WriteResult& result); | 68 void SyncResultIfEnabled(const ValueStore::WriteResult& result); |
69 | 69 |
70 // Sends all local settings to sync (synced settings assumed to be empty). | 70 // Sends all local settings to sync (synced settings assumed to be empty). |
71 syncer::SyncError SendLocalSettingsToSync( | 71 syncer::SyncError SendLocalSettingsToSync( |
72 const DictionaryValue& settings); | 72 const base::DictionaryValue& settings); |
73 | 73 |
74 // Overwrites local state with sync state. | 74 // Overwrites local state with sync state. |
75 syncer::SyncError OverwriteLocalSettingsWithSync( | 75 syncer::SyncError OverwriteLocalSettingsWithSync( |
76 const DictionaryValue& sync_state, const DictionaryValue& settings); | 76 const base::DictionaryValue& sync_state, |
| 77 const base::DictionaryValue& settings); |
77 | 78 |
78 // Called when an Add/Update/Remove comes from sync. Ownership of Value*s | 79 // Called when an Add/Update/Remove comes from sync. Ownership of Value*s |
79 // are taken. | 80 // are taken. |
80 syncer::SyncError OnSyncAdd( | 81 syncer::SyncError OnSyncAdd( |
81 const std::string& key, | 82 const std::string& key, |
82 Value* new_value, | 83 Value* new_value, |
83 ValueStoreChangeList* changes); | 84 ValueStoreChangeList* changes); |
84 syncer::SyncError OnSyncUpdate( | 85 syncer::SyncError OnSyncUpdate( |
85 const std::string& key, | 86 const std::string& key, |
86 Value* old_value, | 87 Value* old_value, |
(...skipping 15 matching lines...) Expand all Loading... |
102 | 103 |
103 // Object which sends changes to sync. | 104 // Object which sends changes to sync. |
104 scoped_ptr<SettingsSyncProcessor> sync_processor_; | 105 scoped_ptr<SettingsSyncProcessor> sync_processor_; |
105 | 106 |
106 DISALLOW_COPY_AND_ASSIGN(SyncableSettingsStorage); | 107 DISALLOW_COPY_AND_ASSIGN(SyncableSettingsStorage); |
107 }; | 108 }; |
108 | 109 |
109 } // namespace extensions | 110 } // namespace extensions |
110 | 111 |
111 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNCABLE_SETTINGS_STORAGE_H_ | 112 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNCABLE_SETTINGS_STORAGE_H_ |
OLD | NEW |