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

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: fun times 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
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..0c09f1d1288b582605418b35dd7a82c56171b9e9 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"
@@ -40,51 +43,37 @@ class SettingSyncData {
~SettingSyncData();
// Returns the type of the sync change; may be ACTION_INVALID.
Devlin 2015/05/19 15:41:55 nit: We almost never document simple accessors. M
not at google - send to devlin 2015/05/19 19:43:58 This comment serves a purpose.
- syncer::SyncChange::SyncChangeType change_type() const;
+ syncer::SyncChange::SyncChangeType change_type() const {
+ return change_type_;
+ }
// Returns the extension id the setting is for.
not at google - send to devlin 2015/05/19 19:43:58 this does not
- const std::string& extension_id() const;
+ const std::string& extension_id() const { return extension_id_; }
// Returns the settings key.
not at google - send to devlin 2015/05/19 19:43:58 nor does this
- const std::string& key() const;
-
- // Returns the value of the setting.
- const base::Value& value() const;
-
- 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);
+ const std::string& key() const { return key_; }
- syncer::SyncChange::SyncChangeType change_type_;
- std::string extension_id_;
- std::string key_;
- scoped_ptr<base::Value> value_;
+ // Returns the value of the setting. Cannot be called if PassValue() has been
+ // called.
not at google - send to devlin 2015/05/19 19:43:57 this does.
+ const base::Value& value() const { return *value_; }
- private:
- friend class base::RefCountedThreadSafe<Internal>;
- ~Internal();
- };
+ // Releases ownership of the value to the caller.
not at google - send to devlin 2015/05/19 19:43:58 I should improve this comment because it's importa
+ scoped_ptr<base::Value> PassValue();
- // Initializes internal_ from sync data for an extension or app setting.
- void Init(syncer::SyncChange::SyncChangeType change_type,
- const syncer::SyncData& sync_data);
+ private:
+ // Populates the extension ID, key, and value from |sync_data|. This will be
+ // either an extension or app settings data type.
+ void Init(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);
Devlin 2015/05/15 23:58:18 Woo!
};
-typedef std::vector<SettingSyncData> SettingSyncDataList;
+typedef ScopedVector<SettingSyncData> SettingSyncDataList;
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698