OLD | NEW |
| (Empty) |
1 // Copyright 2014 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. | |
4 | |
5 #include "chromecast/renderer/cast_render_thread_observer.h" | |
6 | |
7 #include "build/build_config.h" | |
8 #include "chromecast/renderer/media/cma_message_filter_proxy.h" | |
9 #include "content/public/renderer/render_thread.h" | |
10 | |
11 namespace chromecast { | |
12 namespace shell { | |
13 | |
14 CastRenderThreadObserver::CastRenderThreadObserver() { | |
15 content::RenderThread* thread = content::RenderThread::Get(); | |
16 thread->AddObserver(this); | |
17 CreateCustomFilters(); | |
18 } | |
19 | |
20 CastRenderThreadObserver::~CastRenderThreadObserver() { | |
21 // CastRenderThreadObserver outlives content::RenderThread. | |
22 // No need to explicitly call RemoveObserver in teardown. | |
23 } | |
24 | |
25 void CastRenderThreadObserver::CreateCustomFilters() { | |
26 #if !defined(OS_ANDROID) | |
27 content::RenderThread* thread = content::RenderThread::Get(); | |
28 cma_message_filter_proxy_ = | |
29 new media::CmaMessageFilterProxy(thread->GetIOTaskRunner()); | |
30 thread->AddFilter(cma_message_filter_proxy_.get()); | |
31 #endif // !defined(OS_ANDROID) | |
32 } | |
33 | |
34 void CastRenderThreadObserver::OnRenderProcessShutdown() { | |
35 #if !defined(OS_ANDROID) | |
36 content::RenderThread* thread = content::RenderThread::Get(); | |
37 if (cma_message_filter_proxy_.get()) { | |
38 thread->RemoveFilter(cma_message_filter_proxy_.get()); | |
39 cma_message_filter_proxy_ = nullptr; | |
40 } | |
41 #endif // !defined(OS_ANDROID) | |
42 } | |
43 | |
44 } // namespace shell | |
45 } // namespace chromecast | |
OLD | NEW |