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

Side by Side Diff: content/common/property_bag.cc

Issue 8652002: Move PropertyBag to base. Originally this was in chrome\common because only chrome used it. Now t... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: move to base namespace and forward declare where possible Created 9 years, 1 month 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 | « content/common/property_bag.h ('k') | content/common/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/memory/linked_ptr.h"
6 #include "content/common/property_bag.h"
7
8 PropertyBag::PropertyBag() {
9 }
10
11 PropertyBag::PropertyBag(const PropertyBag& other) {
12 operator=(other);
13 }
14
15 PropertyBag::~PropertyBag() {
16 }
17
18 PropertyBag& PropertyBag::operator=(const PropertyBag& other) {
19 props_.clear();
20
21 // We need to make copies of each property using the virtual copy() method.
22 for (PropertyMap::const_iterator i = other.props_.begin();
23 i != other.props_.end(); ++i)
24 props_[i->first] = linked_ptr<Prop>(i->second->copy());
25 return *this;
26 }
27
28 void PropertyBag::SetProperty(PropID id, Prop* prop) {
29 props_[id] = linked_ptr<Prop>(prop);
30 }
31
32 PropertyBag::Prop* PropertyBag::GetProperty(PropID id) {
33 PropertyMap::const_iterator found = props_.find(id);
34 if (found == props_.end())
35 return NULL;
36 return found->second.get();
37 }
38
39 const PropertyBag::Prop* PropertyBag::GetProperty(PropID id) const {
40 PropertyMap::const_iterator found = props_.find(id);
41 if (found == props_.end())
42 return NULL;
43 return found->second.get();
44 }
45
46 void PropertyBag::DeleteProperty(PropID id) {
47 PropertyMap::iterator found = props_.find(id);
48 if (found == props_.end())
49 return; // Not found, nothing to do.
50 props_.erase(found);
51 }
52
53 PropertyAccessorBase::PropertyAccessorBase() {
54 static PropertyBag::PropID next_id = 1;
55 prop_id_ = next_id++;
56 }
OLDNEW
« no previous file with comments | « content/common/property_bag.h ('k') | content/common/property_bag_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698