Add ability to change display settings to chrome.systemInfo.display
[chromium-blink-merge.git] / base / supports_user_data.cc
blob2a0263ed0d1881e6552f04b44a34fadf3e441cb2
1 // Copyright (c) 2012 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.
5 #include "base/supports_user_data.h"
7 namespace base {
9 SupportsUserData::SupportsUserData() {
10 // Harmless to construct on a different thread to subsequent usage.
11 thread_checker_.DetachFromThread();
14 SupportsUserData::Data* SupportsUserData::GetUserData(const void* key) const {
15 DCHECK(thread_checker_.CalledOnValidThread());
16 DataMap::const_iterator found = user_data_.find(key);
17 if (found != user_data_.end())
18 return found->second.get();
19 return NULL;
22 void SupportsUserData::SetUserData(const void* key, Data* data) {
23 DCHECK(thread_checker_.CalledOnValidThread());
24 user_data_[key] = linked_ptr<Data>(data);
27 void SupportsUserData::RemoveUserData(const void* key) {
28 DCHECK(thread_checker_.CalledOnValidThread());
29 user_data_.erase(key);
32 void SupportsUserData::DetachUserDataThread() {
33 thread_checker_.DetachFromThread();
36 SupportsUserData::~SupportsUserData() {
37 DCHECK(thread_checker_.CalledOnValidThread() || user_data_.empty());
40 } // namespace base