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

Side by Side Diff: base/property_bag.cc

Issue 10831407: Kill PropertyBag, switch WebContents to SupportsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 8 years, 4 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
« no previous file with comments | « base/property_bag.h ('k') | base/property_bag_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/property_bag.h"
6
7 #include "base/memory/linked_ptr.h"
8
9 namespace base {
10
11 PropertyBag::PropertyBag() {
12 }
13
14 PropertyBag::PropertyBag(const PropertyBag& other) {
15 operator=(other);
16 }
17
18 PropertyBag::~PropertyBag() {
19 }
20
21 PropertyBag& PropertyBag::operator=(const PropertyBag& other) {
22 props_.clear();
23
24 // We need to make copies of each property using the virtual copy() method.
25 for (PropertyMap::const_iterator i = other.props_.begin();
26 i != other.props_.end(); ++i)
27 props_[i->first] = linked_ptr<Prop>(i->second->copy());
28 return *this;
29 }
30
31 void PropertyBag::SetProperty(PropID id, Prop* prop) {
32 props_[id] = linked_ptr<Prop>(prop);
33 }
34
35 PropertyBag::Prop* PropertyBag::GetProperty(PropID id) {
36 PropertyMap::const_iterator found = props_.find(id);
37 if (found == props_.end())
38 return NULL;
39 return found->second.get();
40 }
41
42 const PropertyBag::Prop* PropertyBag::GetProperty(PropID id) const {
43 PropertyMap::const_iterator found = props_.find(id);
44 if (found == props_.end())
45 return NULL;
46 return found->second.get();
47 }
48
49 void PropertyBag::DeleteProperty(PropID id) {
50 PropertyMap::iterator found = props_.find(id);
51 if (found == props_.end())
52 return; // Not found, nothing to do.
53 props_.erase(found);
54 }
55
56 PropertyAccessorBase::PropertyAccessorBase() {
57 static PropertyBag::PropID next_id = 1;
58 prop_id_ = next_id++;
59 }
60
61 } // namespace base
OLDNEW
« no previous file with comments | « base/property_bag.h ('k') | base/property_bag_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698