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

Side by Side Diff: chrome/browser/extensions/api/storage/syncable_settings_storage.h

Issue 1141963002: Remove a bunch of DeepCopy() calls in the chrome.storage API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 5 years, 7 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
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_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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 WriteResult Remove(const std::string& key) override; 48 WriteResult Remove(const std::string& key) override;
49 WriteResult Remove(const std::vector<std::string>& keys) override; 49 WriteResult Remove(const std::vector<std::string>& keys) override;
50 WriteResult Clear() override; 50 WriteResult Clear() override;
51 bool Restore() override; 51 bool Restore() override;
52 bool RestoreKey(const std::string& key) override; 52 bool RestoreKey(const std::string& key) override;
53 53
54 // Sync-related methods, analogous to those on SyncableService (handled by 54 // Sync-related methods, analogous to those on SyncableService (handled by
55 // ExtensionSettings), but with looser guarantees about when the methods 55 // ExtensionSettings), but with looser guarantees about when the methods
56 // can be called. 56 // can be called.
57 57
58 // Must only be called if sync isn't already active. 58 // Starts syncing this storage area. Must only be called if sync isn't
59 // already active.
60 // |sync_state| is the current state of the extension settings in sync.
61 // |sync_processor| is used to write out any changes.
62 // Returns any error when trying to sync, or an empty error on success.
59 syncer::SyncError StartSyncing( 63 syncer::SyncError StartSyncing(
60 const base::DictionaryValue& sync_state, 64 scoped_ptr<base::DictionaryValue> sync_state,
61 scoped_ptr<SettingsSyncProcessor> sync_processor); 65 scoped_ptr<SettingsSyncProcessor> sync_processor);
62 66
63 // May be called at any time (idempotent). 67 // Stops syncing this storage area. May be called at any time (idempotent).
64 void StopSyncing(); 68 void StopSyncing();
65 69
66 // May be called at any time; changes will be ignored if sync isn't active. 70 // Pushes a list of sync changes into this storage area. May be called at any
67 syncer::SyncError ProcessSyncChanges(const SettingSyncDataList& sync_changes); 71 // time, changes will be ignored if sync isn't active.
72 // Returns any error when trying to sync, or an empty error on success.
73 syncer::SyncError ProcessSyncChanges(
74 scoped_ptr<SettingSyncDataList> sync_changes);
68 75
69 private: 76 private:
70 // Sends the changes from |result| to sync if it's enabled. 77 // Sends the changes from |result| to sync if it's enabled.
71 void SyncResultIfEnabled(const ValueStore::WriteResult& result); 78 void SyncResultIfEnabled(const ValueStore::WriteResult& result);
72 79
73 // Sends all local settings to sync (synced settings assumed to be empty). 80 // Sends all local settings to sync. This assumes that there are no settings
81 // in sync yet.
82 // Returns any error when trying to sync, or an empty error on success.
74 syncer::SyncError SendLocalSettingsToSync( 83 syncer::SyncError SendLocalSettingsToSync(
75 const base::DictionaryValue& settings); 84 scoped_ptr<base::DictionaryValue> local_state);
76 85
77 // Overwrites local state with sync state. 86 // Overwrites local state with sync state.
87 // Returns any error when trying to sync, or an empty error on success.
78 syncer::SyncError OverwriteLocalSettingsWithSync( 88 syncer::SyncError OverwriteLocalSettingsWithSync(
79 const base::DictionaryValue& sync_state, 89 scoped_ptr<base::DictionaryValue> sync_state,
80 const base::DictionaryValue& settings); 90 scoped_ptr<base::DictionaryValue> local_state);
81 91
82 // Called when an Add/Update/Remove comes from sync. Ownership of Value*s 92 // Called when an Add/Update/Remove comes from sync. Ownership of Value*s
83 // are taken. 93 // are taken.
84 syncer::SyncError OnSyncAdd( 94 syncer::SyncError OnSyncAdd(
85 const std::string& key, 95 const std::string& key,
86 base::Value* new_value, 96 base::Value* new_value,
87 ValueStoreChangeList* changes); 97 ValueStoreChangeList* changes);
88 syncer::SyncError OnSyncUpdate( 98 syncer::SyncError OnSyncUpdate(
89 const std::string& key, 99 const std::string& key,
90 base::Value* old_value, 100 base::Value* old_value,
91 base::Value* new_value, 101 base::Value* new_value,
92 ValueStoreChangeList* changes); 102 ValueStoreChangeList* changes);
(...skipping 16 matching lines...) Expand all
109 119
110 const syncer::ModelType sync_type_; 120 const syncer::ModelType sync_type_;
111 const syncer::SyncableService::StartSyncFlare flare_; 121 const syncer::SyncableService::StartSyncFlare flare_;
112 122
113 DISALLOW_COPY_AND_ASSIGN(SyncableSettingsStorage); 123 DISALLOW_COPY_AND_ASSIGN(SyncableSettingsStorage);
114 }; 124 };
115 125
116 } // namespace extensions 126 } // namespace extensions
117 127
118 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNCABLE_SETTINGS_STORAGE_H_ 128 #endif // CHROME_BROWSER_EXTENSIONS_API_STORAGE_SYNCABLE_SETTINGS_STORAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698