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

Unified Diff: base/values.h

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 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 | « base/tracked_objects_unittest.cc ('k') | base/values.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/values.h
diff --git a/base/values.h b/base/values.h
index 141ea934201f5fc449bd8e7074c8c494905b4862..e2506cc14f5515ab9fba9a76c1995fe8575dc9d5 100644
--- a/base/values.h
+++ b/base/values.h
@@ -22,6 +22,7 @@
#include <iosfwd>
#include <map>
+#include <memory>
#include <string>
#include <utility>
#include <vector>
@@ -29,7 +30,6 @@
#include "base/base_export.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "base/strings/string_piece.h"
@@ -66,7 +66,7 @@ class BASE_EXPORT Value {
virtual ~Value();
- static scoped_ptr<Value> CreateNullValue();
+ static std::unique_ptr<Value> CreateNullValue();
// Returns the type of the value stored by the current Value object.
// Each type will be implemented by only one subclass of Value, so it's
@@ -102,7 +102,7 @@ class BASE_EXPORT Value {
// this works because C++ supports covariant return types.
virtual Value* DeepCopy() const;
// Preferred version of DeepCopy. TODO(estade): remove the above.
- scoped_ptr<Value> CreateDeepCopy() const;
+ std::unique_ptr<Value> CreateDeepCopy() const;
// Compares if two Value objects have equal contents.
virtual bool Equals(const Value* other) const;
@@ -178,7 +178,7 @@ class BASE_EXPORT BinaryValue: public Value {
// Creates a BinaryValue, taking ownership of the bytes pointed to by
// |buffer|.
- BinaryValue(scoped_ptr<char[]> buffer, size_t size);
+ BinaryValue(std::unique_ptr<char[]> buffer, size_t size);
~BinaryValue() override;
@@ -199,7 +199,7 @@ class BASE_EXPORT BinaryValue: public Value {
bool Equals(const Value* other) const override;
private:
- scoped_ptr<char[]> buffer_;
+ std::unique_ptr<char[]> buffer_;
size_t size_;
DISALLOW_COPY_AND_ASSIGN(BinaryValue);
@@ -211,7 +211,7 @@ class BASE_EXPORT BinaryValue: public Value {
class BASE_EXPORT DictionaryValue : public Value {
public:
// Returns |value| if it is a dictionary, nullptr otherwise.
- static scoped_ptr<DictionaryValue> From(scoped_ptr<Value> value);
+ static std::unique_ptr<DictionaryValue> From(std::unique_ptr<Value> value);
DictionaryValue();
~DictionaryValue() override;
@@ -239,7 +239,7 @@ class BASE_EXPORT DictionaryValue : public Value {
// If the key at any step of the way doesn't exist, or exists but isn't
// a DictionaryValue, a new DictionaryValue will be created and attached
// to the path in that location. |in_value| must be non-null.
- void Set(const std::string& path, scoped_ptr<Value> in_value);
+ void Set(const std::string& path, std::unique_ptr<Value> in_value);
// Deprecated version of the above. TODO(estade): remove.
void Set(const std::string& path, Value* in_value);
@@ -254,7 +254,7 @@ class BASE_EXPORT DictionaryValue : public Value {
// Like Set(), but without special treatment of '.'. This allows e.g. URLs to
// be used as paths.
void SetWithoutPathExpansion(const std::string& key,
- scoped_ptr<Value> in_value);
+ std::unique_ptr<Value> in_value);
// Deprecated version of the above. TODO(estade): remove.
void SetWithoutPathExpansion(const std::string& key, Value* in_value);
@@ -329,21 +329,22 @@ class BASE_EXPORT DictionaryValue : public Value {
// |out_value|. If |out_value| is NULL, the removed value will be deleted.
// This method returns true if |path| is a valid path; otherwise it will
// return false and the DictionaryValue object will be unchanged.
- virtual bool Remove(const std::string& path, scoped_ptr<Value>* out_value);
+ virtual bool Remove(const std::string& path,
+ std::unique_ptr<Value>* out_value);
// Like Remove(), but without special treatment of '.'. This allows e.g. URLs
// to be used as paths.
virtual bool RemoveWithoutPathExpansion(const std::string& key,
- scoped_ptr<Value>* out_value);
+ std::unique_ptr<Value>* out_value);
// Removes a path, clearing out all dictionaries on |path| that remain empty
// after removing the value at |path|.
virtual bool RemovePath(const std::string& path,
- scoped_ptr<Value>* out_value);
+ std::unique_ptr<Value>* out_value);
// Makes a copy of |this| but doesn't include empty dictionaries and lists in
// the copy. This never returns NULL, even if |this| itself is empty.
- scoped_ptr<DictionaryValue> DeepCopyWithoutEmptyChildren() const;
+ std::unique_ptr<DictionaryValue> DeepCopyWithoutEmptyChildren() const;
// Merge |dictionary| into this dictionary. This is done recursively, i.e. any
// sub-dictionaries will be merged as well. In case of key collisions, the
@@ -377,7 +378,7 @@ class BASE_EXPORT DictionaryValue : public Value {
// Overridden from Value:
DictionaryValue* DeepCopy() const override;
// Preferred version of DeepCopy. TODO(estade): remove the above.
- scoped_ptr<DictionaryValue> CreateDeepCopy() const;
+ std::unique_ptr<DictionaryValue> CreateDeepCopy() const;
bool Equals(const Value* other) const override;
private:
@@ -393,7 +394,7 @@ class BASE_EXPORT ListValue : public Value {
typedef ValueVector::const_iterator const_iterator;
// Returns |value| if it is a list, nullptr otherwise.
- static scoped_ptr<ListValue> From(scoped_ptr<Value> value);
+ static std::unique_ptr<ListValue> From(std::unique_ptr<Value> value);
ListValue();
~ListValue() override;
@@ -414,7 +415,7 @@ class BASE_EXPORT ListValue : public Value {
// the value is a null pointer.
bool Set(size_t index, Value* in_value);
// Preferred version of the above. TODO(estade): remove the above.
- bool Set(size_t index, scoped_ptr<Value> in_value);
+ bool Set(size_t index, std::unique_ptr<Value> in_value);
// Gets the Value at the given index. Modifies |out_value| (and returns true)
// only if the index falls within the current list range.
@@ -446,7 +447,7 @@ class BASE_EXPORT ListValue : public Value {
// passed out via |out_value|. If |out_value| is NULL, the removed value will
// be deleted. This method returns true if |index| is valid; otherwise
// it will return false and the ListValue object will be unchanged.
- virtual bool Remove(size_t index, scoped_ptr<Value>* out_value);
+ virtual bool Remove(size_t index, std::unique_ptr<Value>* out_value);
// Removes the first instance of |value| found in the list, if any, and
// deletes it. |index| is the location where |value| was found. Returns false
@@ -457,10 +458,10 @@ class BASE_EXPORT ListValue : public Value {
// deleted, otherwise ownership of the value is passed back to the caller.
// Returns an iterator pointing to the location of the element that
// followed the erased element.
- iterator Erase(iterator iter, scoped_ptr<Value>* out_value);
+ iterator Erase(iterator iter, std::unique_ptr<Value>* out_value);
// Appends a Value to the end of the list.
- void Append(scoped_ptr<Value> in_value);
+ void Append(std::unique_ptr<Value> in_value);
// Deprecated version of the above. TODO(estade): remove.
void Append(Value* in_value);
@@ -504,7 +505,7 @@ class BASE_EXPORT ListValue : public Value {
bool Equals(const Value* other) const override;
// Preferred version of DeepCopy. TODO(estade): remove DeepCopy.
- scoped_ptr<ListValue> CreateDeepCopy() const;
+ std::unique_ptr<ListValue> CreateDeepCopy() const;
private:
ValueVector list_;
@@ -533,8 +534,8 @@ class BASE_EXPORT ValueDeserializer {
// error_code will be set with the underlying error.
// If |error_message| is non-null, it will be filled in with a formatted
// error message including the location of the error if appropriate.
- virtual scoped_ptr<Value> Deserialize(int* error_code,
- std::string* error_str) = 0;
+ virtual std::unique_ptr<Value> Deserialize(int* error_code,
+ std::string* error_str) = 0;
};
// Stream operator so Values can be used in assertion statements. In order that
« no previous file with comments | « base/tracked_objects_unittest.cc ('k') | base/values.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698