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

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 2498203004: Move media::mojom::RemoterFactory to content, add ContentBrowserClient API. (Closed)
Patch Set: REBASE Created 4 years, 1 month 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 | « content/browser/BUILD.gn ('k') | content/public/browser/content_browser_client.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/frame_host/render_frame_host_impl.h" 5 #include "content/browser/frame_host/render_frame_host_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 #include "content/public/common/isolated_world_ids.h" 89 #include "content/public/common/isolated_world_ids.h"
90 #include "content/public/common/service_manager_connection.h" 90 #include "content/public/common/service_manager_connection.h"
91 #include "content/public/common/service_names.h" 91 #include "content/public/common/service_names.h"
92 #include "content/public/common/url_constants.h" 92 #include "content/public/common/url_constants.h"
93 #include "content/public/common/url_utils.h" 93 #include "content/public/common/url_utils.h"
94 #include "device/generic_sensor/sensor_provider_impl.h" 94 #include "device/generic_sensor/sensor_provider_impl.h"
95 #include "device/geolocation/geolocation_service_context.h" 95 #include "device/geolocation/geolocation_service_context.h"
96 #include "device/vibration/vibration_manager_impl.h" 96 #include "device/vibration/vibration_manager_impl.h"
97 #include "device/wake_lock/wake_lock_service_context.h" 97 #include "device/wake_lock/wake_lock_service_context.h"
98 #include "media/base/media_switches.h" 98 #include "media/base/media_switches.h"
99 #include "media/media_features.h"
99 #include "media/mojo/interfaces/media_service.mojom.h" 100 #include "media/mojo/interfaces/media_service.mojom.h"
101 #include "media/mojo/interfaces/remoting.mojom.h"
100 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" 102 #include "mojo/public/cpp/bindings/associated_interface_ptr.h"
101 #include "mojo/public/cpp/bindings/strong_binding.h" 103 #include "mojo/public/cpp/bindings/strong_binding.h"
102 #include "services/service_manager/public/cpp/connector.h" 104 #include "services/service_manager/public/cpp/connector.h"
103 #include "services/service_manager/public/cpp/interface_provider.h" 105 #include "services/service_manager/public/cpp/interface_provider.h"
104 #include "third_party/WebKit/public/platform/modules/shapedetection/shapedetecti on.mojom.h" 106 #include "third_party/WebKit/public/platform/modules/shapedetection/shapedetecti on.mojom.h"
105 #include "ui/accessibility/ax_tree.h" 107 #include "ui/accessibility/ax_tree.h"
106 #include "ui/accessibility/ax_tree_update.h" 108 #include "ui/accessibility/ax_tree_update.h"
107 #include "ui/gfx/geometry/quad_f.h" 109 #include "ui/gfx/geometry/quad_f.h"
108 #include "url/gurl.h" 110 #include "url/gurl.h"
109 111
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 policy->GrantReadFile(child_id, file); 199 policy->GrantReadFile(child_id, file);
198 } 200 }
199 } 201 }
200 202
201 void NotifyRenderFrameDetachedOnIO(int render_process_id, int render_frame_id) { 203 void NotifyRenderFrameDetachedOnIO(int render_process_id, int render_frame_id) {
202 DCHECK_CURRENTLY_ON(BrowserThread::IO); 204 DCHECK_CURRENTLY_ON(BrowserThread::IO);
203 SharedWorkerServiceImpl::GetInstance()->RenderFrameDetached(render_process_id, 205 SharedWorkerServiceImpl::GetInstance()->RenderFrameDetached(render_process_id,
204 render_frame_id); 206 render_frame_id);
205 } 207 }
206 208
209 #if BUILDFLAG(ENABLE_MEDIA_REMOTING)
210 // RemoterFactory that delegates Create() calls to the ContentBrowserClient.
211 //
212 // Since Create() could be called at any time, perhaps by a stray task being run
213 // after a RenderFrameHost has been destroyed, the RemoterFactoryImpl uses the
214 // process/routing IDs as a weak reference to the RenderFrameHostImpl.
215 class RemoterFactoryImpl final : public media::mojom::RemoterFactory {
216 public:
217 RemoterFactoryImpl(int process_id, int routing_id)
218 : process_id_(process_id), routing_id_(routing_id) {}
219
220 static void Bind(int process_id, int routing_id,
221 media::mojom::RemoterFactoryRequest request) {
222 mojo::MakeStrongBinding(
223 base::MakeUnique<RemoterFactoryImpl>(process_id, routing_id),
224 std::move(request));
225 }
226
227 private:
228 void Create(media::mojom::RemotingSourcePtr source,
229 media::mojom::RemoterRequest request) final {
230 if (auto* host = RenderFrameHostImpl::FromID(process_id_, routing_id_)) {
231 GetContentClient()->browser()->CreateMediaRemoter(
232 host, std::move(source), std::move(request));
233 }
234 }
235
236 const int process_id_;
237 const int routing_id_;
238
239 DISALLOW_COPY_AND_ASSIGN(RemoterFactoryImpl);
240 };
241 #endif // BUILDFLAG(ENABLE_MEDIA_REMOTING)
242
207 } // namespace 243 } // namespace
208 244
209 // static 245 // static
210 RenderFrameHost* RenderFrameHost::FromID(int render_process_id, 246 RenderFrameHost* RenderFrameHost::FromID(int render_process_id,
211 int render_frame_id) { 247 int render_frame_id) {
212 return RenderFrameHostImpl::FromID(render_process_id, render_frame_id); 248 return RenderFrameHostImpl::FromID(render_process_id, render_frame_id);
213 } 249 }
214 250
215 #if defined(OS_ANDROID) 251 #if defined(OS_ANDROID)
216 // static 252 // static
(...skipping 2026 matching lines...) Expand 10 before | Expand all | Expand 10 after
2243 base::Bind(&MediaDevicesDispatcherHost::Create, GetProcess()->GetID(), 2279 base::Bind(&MediaDevicesDispatcherHost::Create, GetProcess()->GetID(),
2244 GetRoutingID(), GetProcess() 2280 GetRoutingID(), GetProcess()
2245 ->GetBrowserContext() 2281 ->GetBrowserContext()
2246 ->GetResourceContext() 2282 ->GetResourceContext()
2247 ->GetMediaDeviceIDSalt(), 2283 ->GetMediaDeviceIDSalt(),
2248 base::Unretained(media_stream_manager)), 2284 base::Unretained(media_stream_manager)),
2249 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); 2285 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO));
2250 } 2286 }
2251 #endif 2287 #endif
2252 2288
2289 #if BUILDFLAG(ENABLE_MEDIA_REMOTING)
2290 GetInterfaceRegistry()->AddInterface(base::Bind(
2291 &RemoterFactoryImpl::Bind, GetProcess()->GetID(), GetRoutingID()));
2292 #endif // BUILDFLAG(ENABLE_MEDIA_REMOTING)
2293
2253 GetContentClient()->browser()->RegisterRenderFrameMojoInterfaces( 2294 GetContentClient()->browser()->RegisterRenderFrameMojoInterfaces(
2254 GetInterfaceRegistry(), this); 2295 GetInterfaceRegistry(), this);
2255 } 2296 }
2256 2297
2257 void RenderFrameHostImpl::ResetWaitingState() { 2298 void RenderFrameHostImpl::ResetWaitingState() {
2258 DCHECK(is_active()); 2299 DCHECK(is_active());
2259 2300
2260 // Whenever we reset the RFH state, we should not be waiting for beforeunload 2301 // Whenever we reset the RFH state, we should not be waiting for beforeunload
2261 // or close acks. We clear them here to be safe, since they can cause 2302 // or close acks. We clear them here to be safe, since they can cause
2262 // navigations to be ignored in OnDidCommitProvisionalLoad. 2303 // navigations to be ignored in OnDidCommitProvisionalLoad.
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
3267 // There is no pending NavigationEntry in these cases, so pass 0 as the 3308 // There is no pending NavigationEntry in these cases, so pass 0 as the
3268 // pending_nav_entry_id. If the previous handle was a prematurely aborted 3309 // pending_nav_entry_id. If the previous handle was a prematurely aborted
3269 // navigation loaded via LoadDataWithBaseURL, propagate the entry id. 3310 // navigation loaded via LoadDataWithBaseURL, propagate the entry id.
3270 return NavigationHandleImpl::Create( 3311 return NavigationHandleImpl::Create(
3271 params.url, frame_tree_node_, is_renderer_initiated, 3312 params.url, frame_tree_node_, is_renderer_initiated,
3272 params.was_within_same_page, params.is_srcdoc, base::TimeTicks::Now(), 3313 params.was_within_same_page, params.is_srcdoc, base::TimeTicks::Now(),
3273 entry_id_for_data_nav, false); // started_from_context_menu 3314 entry_id_for_data_nav, false); // started_from_context_menu
3274 } 3315 }
3275 3316
3276 } // namespace content 3317 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/BUILD.gn ('k') | content/public/browser/content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698