| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 115 } |
| 116 | 116 |
| 117 scoped_refptr<media::AudioRendererSink> AudioRendererSinkCacheImpl::GetSink( | 117 scoped_refptr<media::AudioRendererSink> AudioRendererSinkCacheImpl::GetSink( |
| 118 int source_render_frame_id, | 118 int source_render_frame_id, |
| 119 const std::string& device_id, | 119 const std::string& device_id, |
| 120 const url::Origin& security_origin) { | 120 const url::Origin& security_origin) { |
| 121 base::AutoLock auto_lock(cache_lock_); | 121 base::AutoLock auto_lock(cache_lock_); |
| 122 | 122 |
| 123 auto cache_iter = | 123 auto cache_iter = |
| 124 FindCacheEntry_Locked(source_render_frame_id, device_id, security_origin, | 124 FindCacheEntry_Locked(source_render_frame_id, device_id, security_origin, |
| 125 true /* unused_only */); | 125 true /* unused sink only */); |
| 126 | 126 |
| 127 if (cache_iter != cache_.end()) { | 127 if (cache_iter != cache_.end()) { |
| 128 // Found unused sink; mark it as used and return. | 128 // Found unused sink; mark it as used and return. |
| 129 DVLOG(1) << "GetSink: address: " << cache_iter->sink.get() | 129 DVLOG(1) << "GetSink: address: " << cache_iter->sink.get() |
| 130 << " - found unused cached sink, reusing it."; | 130 << " - found unused cached sink, reusing it."; |
| 131 | 131 |
| 132 cache_iter->used = true; | 132 cache_iter->used = true; |
| 133 return cache_iter->sink; | 133 return cache_iter->sink; |
| 134 } | 134 } |
| 135 | 135 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 return val.device_id == device_id && | 244 return val.device_id == device_id && |
| 245 val.security_origin == security_origin; | 245 val.security_origin == security_origin; |
| 246 }); | 246 }); |
| 247 }; | 247 }; |
| 248 | 248 |
| 249 int AudioRendererSinkCacheImpl::GetCacheSizeForTesting() { | 249 int AudioRendererSinkCacheImpl::GetCacheSizeForTesting() { |
| 250 return cache_.size(); | 250 return cache_.size(); |
| 251 } | 251 } |
| 252 | 252 |
| 253 } // namespace content | 253 } // namespace content |
| OLD | NEW |