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

Side by Side Diff: chromecast/base/device_capabilities_impl.cc

Issue 1884453002: Revert of Convert //net and //chromecast to std::unordered_* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « chromecast/base/device_capabilities_impl.h ('k') | chromecast/common/cast_resource_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "chromecast/base/device_capabilities_impl.h" 5 #include "chromecast/base/device_capabilities_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // Make sure that all observers have been removed at this point 142 // Make sure that all observers have been removed at this point
143 observer_list_->AssertEmpty(); 143 observer_list_->AssertEmpty();
144 } 144 }
145 145
146 void DeviceCapabilitiesImpl::Register(const std::string& key, 146 void DeviceCapabilitiesImpl::Register(const std::string& key,
147 Validator* validator) { 147 Validator* validator) {
148 DCHECK(IsValidRegisterKey(key)); 148 DCHECK(IsValidRegisterKey(key));
149 DCHECK(validator); 149 DCHECK(validator);
150 150
151 base::AutoLock auto_lock(validation_lock_); 151 base::AutoLock auto_lock(validation_lock_);
152 bool added =
153 validator_map_.add(key, base::WrapUnique(new ValidatorInfo(validator)))
154 .second;
152 // Check that a validator has not already been registered for this key 155 // Check that a validator has not already been registered for this key
153 DCHECK_EQ(0u, validator_map_.count(key)); 156 DCHECK(added);
154 validator_map_[key] = base::WrapUnique(new ValidatorInfo(validator));
155 } 157 }
156 158
157 void DeviceCapabilitiesImpl::Unregister(const std::string& key, 159 void DeviceCapabilitiesImpl::Unregister(const std::string& key,
158 const Validator* validator) { 160 const Validator* validator) {
159 base::AutoLock auto_lock(validation_lock_); 161 base::AutoLock auto_lock(validation_lock_);
160 auto validator_it = validator_map_.find(key); 162 auto validator_it = validator_map_.find(key);
161 DCHECK(validator_it != validator_map_.end()); 163 DCHECK(validator_it != validator_map_.end());
162 // Check that validator being unregistered matches the original for |key|. 164 // Check that validator being unregistered matches the original for |key|.
163 // This prevents managers from accidentally unregistering incorrect 165 // This prevents managers from accidentally unregistering incorrect
164 // validators. 166 // validators.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 } 320 }
319 321
320 // Even though ObserverListThreadSafe notifications are always asynchronous 322 // Even though ObserverListThreadSafe notifications are always asynchronous
321 // (posts task even if to same thread), no locks should be held at this point 323 // (posts task even if to same thread), no locks should be held at this point
322 // in the code. This is just to be safe that no deadlocks occur if Observers 324 // in the code. This is just to be safe that no deadlocks occur if Observers
323 // call DeviceCapabilities methods in OnCapabilitiesChanged(). 325 // call DeviceCapabilities methods in OnCapabilitiesChanged().
324 observer_list_->Notify(FROM_HERE, &Observer::OnCapabilitiesChanged, path); 326 observer_list_->Notify(FROM_HERE, &Observer::OnCapabilitiesChanged, path);
325 } 327 }
326 328
327 } // namespace chromecast 329 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/base/device_capabilities_impl.h ('k') | chromecast/common/cast_resource_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698