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

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

Issue 1897033002: Reland 'Convert //net and //chromecast to std::unordered_*' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix TestDownloadRequestHandler 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;
155 // Check that a validator has not already been registered for this key 152 // Check that a validator has not already been registered for this key
156 DCHECK(added); 153 DCHECK_EQ(0u, validator_map_.count(key));
154 validator_map_[key] = base::WrapUnique(new ValidatorInfo(validator));
157 } 155 }
158 156
159 void DeviceCapabilitiesImpl::Unregister(const std::string& key, 157 void DeviceCapabilitiesImpl::Unregister(const std::string& key,
160 const Validator* validator) { 158 const Validator* validator) {
161 base::AutoLock auto_lock(validation_lock_); 159 base::AutoLock auto_lock(validation_lock_);
162 auto validator_it = validator_map_.find(key); 160 auto validator_it = validator_map_.find(key);
163 DCHECK(validator_it != validator_map_.end()); 161 DCHECK(validator_it != validator_map_.end());
164 // Check that validator being unregistered matches the original for |key|. 162 // Check that validator being unregistered matches the original for |key|.
165 // This prevents managers from accidentally unregistering incorrect 163 // This prevents managers from accidentally unregistering incorrect
166 // validators. 164 // validators.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 318 }
321 319
322 // Even though ObserverListThreadSafe notifications are always asynchronous 320 // Even though ObserverListThreadSafe notifications are always asynchronous
323 // (posts task even if to same thread), no locks should be held at this point 321 // (posts task even if to same thread), no locks should be held at this point
324 // in the code. This is just to be safe that no deadlocks occur if Observers 322 // in the code. This is just to be safe that no deadlocks occur if Observers
325 // call DeviceCapabilities methods in OnCapabilitiesChanged(). 323 // call DeviceCapabilities methods in OnCapabilitiesChanged().
326 observer_list_->Notify(FROM_HERE, &Observer::OnCapabilitiesChanged, path); 324 observer_list_->Notify(FROM_HERE, &Observer::OnCapabilitiesChanged, path);
327 } 325 }
328 326
329 } // namespace chromecast 327 } // 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