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

Unified Diff: chrome/browser/extensions/api/storage/setting_sync_data.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/api/storage/setting_sync_data.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/storage/setting_sync_data.h
diff --git a/chrome/browser/extensions/api/storage/setting_sync_data.h b/chrome/browser/extensions/api/storage/setting_sync_data.h
index 8fc0f91870307b233dd98c943eb1196e5ca5f21c..181e3e70a5e291fe34efa41dedd487ee4697ae77 100644
--- a/chrome/browser/extensions/api/storage/setting_sync_data.h
+++ b/chrome/browser/extensions/api/storage/setting_sync_data.h
@@ -5,8 +5,11 @@
#ifndef CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTING_SYNC_DATA_H_
#define CHROME_BROWSER_EXTENSIONS_API_STORAGE_SETTING_SYNC_DATA_H_
-#include "base/memory/ref_counted.h"
+#include <string>
+
+#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_vector.h"
#include "base/values.h"
#include "sync/api/sync_change.h"
@@ -39,52 +42,34 @@ class SettingSyncData {
~SettingSyncData();
- // Returns the type of the sync change; may be ACTION_INVALID.
- syncer::SyncChange::SyncChangeType change_type() const;
-
- // Returns the extension id the setting is for.
- const std::string& extension_id() const;
-
- // Returns the settings key.
- const std::string& key() const;
+ // May return ACTION_INVALID if this object represents sync data that isn't
+ // associated with a sync operation.
+ syncer::SyncChange::SyncChangeType change_type() const {
+ return change_type_;
+ }
+ const std::string& extension_id() const { return extension_id_; }
+ const std::string& key() const { return key_; }
+ // value() cannot be called if PassValue() has been called.
+ const base::Value& value() const { return *value_; }
- // Returns the value of the setting.
- const base::Value& value() const;
+ // Releases ownership of the value to the caller. Neither value() nor
+ // PassValue() can be after this.
+ scoped_ptr<base::Value> PassValue();
private:
- // Ref-counted container for the data.
- // TODO(kalman): Use browser_sync::Immutable<Internal>.
- class Internal : public base::RefCountedThreadSafe<Internal> {
- public:
- Internal(
- syncer::SyncChange::SyncChangeType change_type,
- const std::string& extension_id,
- const std::string& key,
- scoped_ptr<base::Value> value);
-
- syncer::SyncChange::SyncChangeType change_type_;
- std::string extension_id_;
- std::string key_;
- scoped_ptr<base::Value> value_;
-
- private:
- friend class base::RefCountedThreadSafe<Internal>;
- ~Internal();
- };
+ // Populates the extension ID, key, and value from |sync_data|. This will be
+ // either an extension or app settings data type.
+ void ExtractSyncData(const syncer::SyncData& sync_data);
- // Initializes internal_ from sync data for an extension or app setting.
- void Init(syncer::SyncChange::SyncChangeType change_type,
- const syncer::SyncData& sync_data);
-
- // Initializes internal_ from extension specifics.
- void InitFromExtensionSettingSpecifics(
- syncer::SyncChange::SyncChangeType change_type,
- const sync_pb::ExtensionSettingSpecifics& specifics);
+ syncer::SyncChange::SyncChangeType change_type_;
+ std::string extension_id_;
+ std::string key_;
+ scoped_ptr<base::Value> value_;
- scoped_refptr<Internal> internal_;
+ DISALLOW_COPY_AND_ASSIGN(SettingSyncData);
};
-typedef std::vector<SettingSyncData> SettingSyncDataList;
+typedef ScopedVector<SettingSyncData> SettingSyncDataList;
} // namespace extensions
« no previous file with comments | « no previous file | chrome/browser/extensions/api/storage/setting_sync_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698