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 "content/browser/media/media_interface_proxy.h" | 5 #include "content/browser/media/media_interface_proxy.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "content/public/browser/content_browser_client.h" | 11 #include "content/public/browser/content_browser_client.h" |
12 #include "content/public/browser/render_frame_host.h" | 12 #include "content/public/browser/render_frame_host.h" |
13 #include "content/public/common/content_client.h" | 13 #include "content/public/common/content_client.h" |
14 #include "content/public/common/service_manager_connection.h" | 14 #include "content/public/common/service_manager_connection.h" |
15 #include "media/mojo/interfaces/media_service.mojom.h" | 15 #include "media/mojo/interfaces/media_service.mojom.h" |
| 16 #include "media/mojo/services/media_interface_provider.h" |
16 #include "services/service_manager/public/cpp/connector.h" | 17 #include "services/service_manager/public/cpp/connector.h" |
17 | 18 |
18 #if defined(ENABLE_MOJO_CDM) | 19 #if defined(ENABLE_MOJO_CDM) |
19 #include "content/public/browser/browser_context.h" | 20 #include "content/public/browser/browser_context.h" |
20 #include "content/public/browser/provision_fetcher_impl.h" | 21 #include "content/public/browser/provision_fetcher_impl.h" |
21 #include "content/public/browser/render_process_host.h" | 22 #include "content/public/browser/render_process_host.h" |
22 #include "content/public/browser/storage_partition.h" | 23 #include "content/public/browser/storage_partition.h" |
23 #include "net/url_request/url_request_context_getter.h" | 24 #include "net/url_request/url_request_context_getter.h" |
24 #endif | 25 #endif |
25 | 26 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 92 |
92 interface_factory_ptr_.reset(); | 93 interface_factory_ptr_.reset(); |
93 } | 94 } |
94 | 95 |
95 void MediaInterfaceProxy::ConnectToService() { | 96 void MediaInterfaceProxy::ConnectToService() { |
96 DVLOG(1) << __FUNCTION__; | 97 DVLOG(1) << __FUNCTION__; |
97 DCHECK(thread_checker_.CalledOnValidThread()); | 98 DCHECK(thread_checker_.CalledOnValidThread()); |
98 DCHECK(!interface_factory_ptr_); | 99 DCHECK(!interface_factory_ptr_); |
99 | 100 |
100 // Register frame services. | 101 // Register frame services. |
101 auto registry = | 102 service_manager::mojom::InterfaceProviderPtr interfaces; |
102 base::MakeUnique<service_manager::InterfaceRegistry>(std::string()); | 103 // TODO(xhwang): Replace this InterfaceProvider with a dedicated media host |
| 104 // interface. See http://crbug.com/660573 |
| 105 auto provider = base::MakeUnique<media::MediaInterfaceProvider>( |
| 106 mojo::MakeRequest(&interfaces)); |
103 #if defined(ENABLE_MOJO_CDM) | 107 #if defined(ENABLE_MOJO_CDM) |
104 // TODO(slan): Wrap these into a RenderFrame specific ProvisionFetcher impl. | 108 // TODO(slan): Wrap these into a RenderFrame specific ProvisionFetcher impl. |
105 net::URLRequestContextGetter* context_getter = | 109 net::URLRequestContextGetter* context_getter = |
106 BrowserContext::GetDefaultStoragePartition( | 110 BrowserContext::GetDefaultStoragePartition( |
107 render_frame_host_->GetProcess()->GetBrowserContext()) | 111 render_frame_host_->GetProcess()->GetBrowserContext()) |
108 ->GetURLRequestContext(); | 112 ->GetURLRequestContext(); |
109 registry->AddInterface( | 113 provider->registry()->AddInterface( |
110 base::Bind(&ProvisionFetcherImpl::Create, context_getter)); | 114 base::Bind(&ProvisionFetcherImpl::Create, context_getter)); |
111 #endif // defined(ENABLE_MOJO_CDM) | 115 #endif // defined(ENABLE_MOJO_CDM) |
112 GetContentClient()->browser()->ExposeInterfacesToMediaService( | 116 GetContentClient()->browser()->ExposeInterfacesToMediaService( |
113 registry.get(), render_frame_host_); | 117 provider->registry(), render_frame_host_); |
114 | 118 |
115 // Get frame service InterfaceProvider. | 119 media_registries_.push_back(std::move(provider)); |
116 // TODO(xhwang): Replace this InterfaceProvider with a dedicated media host | |
117 // interface. See http://crbug.com/660573 | |
118 service_manager::mojom::InterfaceProviderPtr interfaces; | |
119 registry->Bind(MakeRequest(&interfaces), service_manager::Identity(), | |
120 service_manager::InterfaceProviderSpec(), | |
121 service_manager::Identity(), | |
122 service_manager::InterfaceProviderSpec()); | |
123 media_registries_.push_back(std::move(registry)); | |
124 | 120 |
125 // TODO(slan): Use the BrowserContext Connector instead. See crbug.com/638950. | 121 // TODO(slan): Use the BrowserContext Connector instead. See crbug.com/638950. |
126 media::mojom::MediaServicePtr media_service; | 122 media::mojom::MediaServicePtr media_service; |
127 service_manager::Connector* connector = | 123 service_manager::Connector* connector = |
128 ServiceManagerConnection::GetForProcess()->GetConnector(); | 124 ServiceManagerConnection::GetForProcess()->GetConnector(); |
129 connector->BindInterface("media", &media_service); | 125 connector->BindInterface("media", &media_service); |
130 media_service->CreateInterfaceFactory(MakeRequest(&interface_factory_ptr_), | 126 media_service->CreateInterfaceFactory(MakeRequest(&interface_factory_ptr_), |
131 std::move(interfaces)); | 127 std::move(interfaces)); |
132 interface_factory_ptr_.set_connection_error_handler(base::Bind( | 128 interface_factory_ptr_.set_connection_error_handler(base::Bind( |
133 &MediaInterfaceProxy::OnConnectionError, base::Unretained(this))); | 129 &MediaInterfaceProxy::OnConnectionError, base::Unretained(this))); |
134 } | 130 } |
135 | 131 |
136 } // namespace content | 132 } // namespace content |
OLD | NEW |