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

Side by Side Diff: base/values.h

Issue 7745040: [Sync] Make P2PNotifier behave more like InvalidationNotifier (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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 // This file specifies a recursive data storage class called Value intended for 5 // This file specifies a recursive data storage class called Value intended for
6 // storing setting and other persistable data. It includes the ability to 6 // storing setting and other persistable data. It includes the ability to
7 // specify (recursive) lists and dictionaries, so it's fairly expressive. 7 // specify (recursive) lists and dictionaries, so it's fairly expressive.
8 // However, the API is optimized for the common case, namely storing a 8 // However, the API is optimized for the common case, namely storing a
9 // hierarchical tree of simple values. Given a DictionaryValue root, you can 9 // hierarchical tree of simple values. Given a DictionaryValue root, you can
10 // easily do things like: 10 // easily do things like:
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // If the current setting object can be converted into the given type, 94 // If the current setting object can be converted into the given type,
95 // the value is returned through the |out_value| parameter and true is 95 // the value is returned through the |out_value| parameter and true is
96 // returned; otherwise, false is returned and |out_value| is unchanged. 96 // returned; otherwise, false is returned and |out_value| is unchanged.
97 virtual bool GetAsBoolean(bool* out_value) const; 97 virtual bool GetAsBoolean(bool* out_value) const;
98 virtual bool GetAsInteger(int* out_value) const; 98 virtual bool GetAsInteger(int* out_value) const;
99 virtual bool GetAsDouble(double* out_value) const; 99 virtual bool GetAsDouble(double* out_value) const;
100 virtual bool GetAsString(std::string* out_value) const; 100 virtual bool GetAsString(std::string* out_value) const;
101 virtual bool GetAsString(string16* out_value) const; 101 virtual bool GetAsString(string16* out_value) const;
102 virtual bool GetAsList(ListValue** out_value); 102 virtual bool GetAsList(ListValue** out_value);
103 virtual bool GetAsList(const ListValue** out_value) const; 103 virtual bool GetAsList(const ListValue** out_value) const;
104 virtual bool GetAsDictionary(DictionaryValue** out_value);
105 virtual bool GetAsDictionary(const DictionaryValue** out_value) const;
Evan Martin 2011/08/26 18:46:33 I think we're trying to move to a different API, l
akalin 2011/08/26 18:56:43 Okay. It seems kinda weird to have a mixture of o
tfarina 2011/08/26 18:59:06 Don't need to add AsDictionary in this patch. The
104 106
105 // This creates a deep copy of the entire Value tree, and returns a pointer 107 // This creates a deep copy of the entire Value tree, and returns a pointer
106 // to the copy. The caller gets ownership of the copy, of course. 108 // to the copy. The caller gets ownership of the copy, of course.
107 // 109 //
108 // Subclasses return their own type directly in their overrides; 110 // Subclasses return their own type directly in their overrides;
109 // this works because C++ supports covariant return types. 111 // this works because C++ supports covariant return types.
110 virtual Value* DeepCopy() const; 112 virtual Value* DeepCopy() const;
111 113
112 // Compares if two Value objects have equal contents. 114 // Compares if two Value objects have equal contents.
113 virtual bool Equals(const Value* other) const; 115 virtual bool Equals(const Value* other) const;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 bool operator==(const key_iterator& other) { return itr_ == other.itr_; } 342 bool operator==(const key_iterator& other) { return itr_ == other.itr_; }
341 343
342 private: 344 private:
343 ValueMap::const_iterator itr_; 345 ValueMap::const_iterator itr_;
344 }; 346 };
345 347
346 key_iterator begin_keys() const { return key_iterator(dictionary_.begin()); } 348 key_iterator begin_keys() const { return key_iterator(dictionary_.begin()); }
347 key_iterator end_keys() const { return key_iterator(dictionary_.end()); } 349 key_iterator end_keys() const { return key_iterator(dictionary_.end()); }
348 350
349 // Overridden from Value: 351 // Overridden from Value:
352 virtual bool GetAsDictionary(DictionaryValue** out_value) OVERRIDE;
353 virtual bool GetAsDictionary(
354 const DictionaryValue** out_value) const OVERRIDE;
350 virtual DictionaryValue* DeepCopy() const OVERRIDE; 355 virtual DictionaryValue* DeepCopy() const OVERRIDE;
351 virtual bool Equals(const Value* other) const OVERRIDE; 356 virtual bool Equals(const Value* other) const OVERRIDE;
352 357
353 private: 358 private:
354 ValueMap dictionary_; 359 ValueMap dictionary_;
355 360
356 DISALLOW_COPY_AND_ASSIGN(DictionaryValue); 361 DISALLOW_COPY_AND_ASSIGN(DictionaryValue);
357 }; 362 };
358 363
359 // This type of Value represents a list of other Value values. 364 // This type of Value represents a list of other Value values.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 471
467 } // namespace base 472 } // namespace base
468 473
469 // http://crbug.com/88666 474 // http://crbug.com/88666
470 using base::DictionaryValue; 475 using base::DictionaryValue;
471 using base::ListValue; 476 using base::ListValue;
472 using base::StringValue; 477 using base::StringValue;
473 using base::Value; 478 using base::Value;
474 479
475 #endif // BASE_VALUES_H_ 480 #endif // BASE_VALUES_H_
OLDNEW
« no previous file with comments | « no previous file | base/values.cc » ('j') | chrome/browser/sync/notifier/invalidation_notifier_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698