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

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

Issue 8361027: Re-commit 106660 with the crashing test disabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 9 years, 2 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) 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_SYNCABLE_EXTENSION_SETTINGS_STORAGE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_SYNCABLE_EXTENSION_SETTINGS_STORAGE_H_
6 #define CHROME_BROWSER_EXTENSIONS_SYNCABLE_EXTENSION_SETTINGS_STORAGE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_SYNCABLE_EXTENSION_SETTINGS_STORAGE_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/observer_list_threadsafe.h"
11 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/extensions/extension_settings_observer.h"
12 #include "chrome/browser/extensions/extension_settings_storage.h" 14 #include "chrome/browser/extensions/extension_settings_storage.h"
13 #include "chrome/browser/extensions/extension_setting_sync_data.h" 15 #include "chrome/browser/extensions/extension_setting_sync_data.h"
14 #include "chrome/browser/sync/api/syncable_service.h" 16 #include "chrome/browser/sync/api/syncable_service.h"
15 #include "chrome/browser/sync/api/sync_change.h" 17 #include "chrome/browser/sync/api/sync_change.h"
16 18
17 // Decorates an ExtensionSettingsStorage with sync behaviour. 19 // Decorates an ExtensionSettingsStorage with sync behaviour.
18 class SyncableExtensionSettingsStorage : public ExtensionSettingsStorage { 20 class SyncableExtensionSettingsStorage : public ExtensionSettingsStorage {
19 public: 21 public:
20 explicit SyncableExtensionSettingsStorage( 22 explicit SyncableExtensionSettingsStorage(
21 std::string extension_id, 23 const scoped_refptr<ObserverListThreadSafe<ExtensionSettingsObserver> >&
24 observers,
25 const std::string& extension_id,
22 // Ownership taken. 26 // Ownership taken.
23 ExtensionSettingsStorage* delegate); 27 ExtensionSettingsStorage* delegate);
24 28
25 virtual ~SyncableExtensionSettingsStorage(); 29 virtual ~SyncableExtensionSettingsStorage();
26 30
27 // ExtensionSettingsStorage implementation. 31 // ExtensionSettingsStorage implementation.
28 virtual Result Get(const std::string& key) OVERRIDE; 32 virtual Result Get(const std::string& key) OVERRIDE;
29 virtual Result Get(const std::vector<std::string>& keys) OVERRIDE; 33 virtual Result Get(const std::vector<std::string>& keys) OVERRIDE;
30 virtual Result Get() OVERRIDE; 34 virtual Result Get() OVERRIDE;
31 virtual Result Set(const std::string& key, const Value& value) OVERRIDE; 35 virtual Result Set(const std::string& key, const Value& value) OVERRIDE;
(...skipping 23 matching lines...) Expand all
55 void SendDeletesToSync(const std::set<std::string>& keys); 59 void SendDeletesToSync(const std::set<std::string>& keys);
56 60
57 // Sends all local settings to sync (synced settings assumed to be empty). 61 // Sends all local settings to sync (synced settings assumed to be empty).
58 SyncError SendLocalSettingsToSync( 62 SyncError SendLocalSettingsToSync(
59 const DictionaryValue& settings); 63 const DictionaryValue& settings);
60 64
61 // Overwrites local state with sync state. 65 // Overwrites local state with sync state.
62 SyncError OverwriteLocalSettingsWithSync( 66 SyncError OverwriteLocalSettingsWithSync(
63 const DictionaryValue& sync_state, const DictionaryValue& settings); 67 const DictionaryValue& sync_state, const DictionaryValue& settings);
64 68
69 // Called when an Add/Update/Remove comes from sync. Ownership of Value*s
70 // are taken.
71 SyncError OnSyncAdd(
72 const std::string& key,
73 Value* new_value,
74 ExtensionSettingChanges::Builder* changes);
75 SyncError OnSyncUpdate(
76 const std::string& key,
77 Value* old_value,
78 Value* new_value,
79 ExtensionSettingChanges::Builder* changes);
80 SyncError OnSyncDelete(
81 const std::string& key,
82 Value* old_value,
83 ExtensionSettingChanges::Builder* changes);
84
85 // List of observers to settings changes.
86 const scoped_refptr<ObserverListThreadSafe<ExtensionSettingsObserver> >
87 observers_;
88
65 // Id of the extension these settings are for. 89 // Id of the extension these settings are for.
66 std::string const extension_id_; 90 std::string const extension_id_;
67 91
68 // Storage area to sync. 92 // Storage area to sync.
69 const scoped_ptr<ExtensionSettingsStorage> delegate_; 93 const scoped_ptr<ExtensionSettingsStorage> delegate_;
70 94
71 // Sync processor. Non-NULL while sync is enabled (between calls to 95 // Sync processor. Non-NULL while sync is enabled (between calls to
72 // StartSyncing and StopSyncing). 96 // StartSyncing and StopSyncing).
73 SyncChangeProcessor* sync_processor_; 97 SyncChangeProcessor* sync_processor_;
74 98
75 // Keys of the settings that are currently being synced. 99 // Keys of the settings that are currently being synced. Only used to decide
100 // whether an ACTION_ADD or ACTION_UPDATE should be sent to sync on a Set().
76 std::set<std::string> synced_keys_; 101 std::set<std::string> synced_keys_;
77 102
78 DISALLOW_COPY_AND_ASSIGN(SyncableExtensionSettingsStorage); 103 DISALLOW_COPY_AND_ASSIGN(SyncableExtensionSettingsStorage);
79 }; 104 };
80 105
81 #endif // CHROME_BROWSER_EXTENSIONS_SYNCABLE_EXTENSION_SETTINGS_STORAGE_H_ 106 #endif // CHROME_BROWSER_EXTENSIONS_SYNCABLE_EXTENSION_SETTINGS_STORAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698