Chromium Code Reviews| 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 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_SINK_CACHE_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_SINK_CACHE_IMPL_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_SINK_CACHE_IMPL_H_ | 6 #define CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_SINK_CACHE_IMPL_H_ |
| 7 | 7 |
| 8 #include "content/renderer/media/audio_renderer_sink_cache.h" | 8 #include "content/renderer/media/audio_renderer_sink_cache.h" |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/optional.h" | |
| 12 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 13 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 19 // AudioRendererSinkCache implementation. | 20 // AudioRendererSinkCache implementation. |
| 20 class CONTENT_EXPORT AudioRendererSinkCacheImpl | 21 class CONTENT_EXPORT AudioRendererSinkCacheImpl |
| 21 : public AudioRendererSinkCache { | 22 : public AudioRendererSinkCache { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 // the same sink is requested in GetSink(), if time interval between (1) and | 85 // the same sink is requested in GetSink(), if time interval between (1) and |
| 85 // (2) is less than |kDeleteTimeoutMs|, then sink cached in (1) is reused in | 86 // (2) is less than |kDeleteTimeoutMs|, then sink cached in (1) is reused in |
| 86 // (2). On the other hand, if after (1) nobody is interested in the sink | 87 // (2). On the other hand, if after (1) nobody is interested in the sink |
| 87 // within |kDeleteTimeoutMs|, it is garbage-collected. | 88 // within |kDeleteTimeoutMs|, it is garbage-collected. |
| 88 const base::TimeDelta delete_timeout_; | 89 const base::TimeDelta delete_timeout_; |
| 89 | 90 |
| 90 // Cached sinks, protected by lock. | 91 // Cached sinks, protected by lock. |
| 91 base::Lock cache_lock_; | 92 base::Lock cache_lock_; |
| 92 CacheContainer cache_; | 93 CacheContainer cache_; |
| 93 | 94 |
| 95 // Cached default output device information. Since access to the default | |
| 96 // device is always allowed, this information can be cashed and shared among | |
|
DaleCurtis
2016/07/06 18:53:37
cached.
o1ka
2016/07/13 09:52:41
n/a any more
| |
| 97 // all the clients. It is updated on the first request if not initialized yet, | |
| 98 // and each time a new default device sink is created in the cache. | |
| 99 base::Optional<media::OutputDeviceInfo> default_device_info_; | |
| 100 | |
| 94 // Weak pointer to be used for delayed sink deletion on |task_runner_|. | 101 // Weak pointer to be used for delayed sink deletion on |task_runner_|. |
| 95 // Pre-created in constructor and is used to post all the delayed tasks. | 102 // Pre-created in constructor and is used to post all the delayed tasks. |
| 96 // A delayed task can be concurrently posted from any thread the cache is used | 103 // A delayed task can be concurrently posted from any thread the cache is used |
| 97 // on, so on-the-flight weak pointer creation with | 104 // on, so on-the-flight weak pointer creation with |
| 98 // weak_ptr_factory_.GetWeakPtr() can't be used, because it will result in the | 105 // weak_ptr_factory_.GetWeakPtr() can't be used, because it will result in the |
| 99 // racy access to the factory. | 106 // racy access to the factory. |
| 100 base::WeakPtr<AudioRendererSinkCacheImpl> weak_this_; | 107 base::WeakPtr<AudioRendererSinkCacheImpl> weak_this_; |
| 101 | 108 |
| 102 // Used to produce |weak_this_| on AudioRendererSinkCacheImpl construction. | 109 // Used to produce |weak_this_| on AudioRendererSinkCacheImpl construction. |
| 103 base::WeakPtrFactory<AudioRendererSinkCacheImpl> weak_ptr_factory_; | 110 base::WeakPtrFactory<AudioRendererSinkCacheImpl> weak_ptr_factory_; |
| 104 | 111 |
| 105 DISALLOW_COPY_AND_ASSIGN(AudioRendererSinkCacheImpl); | 112 DISALLOW_COPY_AND_ASSIGN(AudioRendererSinkCacheImpl); |
| 106 }; | 113 }; |
| 107 | 114 |
| 108 } // namespace content | 115 } // namespace content |
| 109 | 116 |
| 110 #endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_SINK_CACHE_IMPL_H_ | 117 #endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_SINK_CACHE_IMPL_H_ |
| OLD | NEW |