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

Side by Side Diff: content/renderer/renderer_blink_platform_impl.cc

Issue 2864023003: Fix the current per-frame URLLoaderFactory code path. (Closed)
Patch Set: Created 3 years, 7 months 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/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/renderer_blink_platform_impl.h" 5 #include "content/renderer/renderer_blink_platform_impl.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "content/renderer/image_capture/image_capture_frame_grabber.h" 56 #include "content/renderer/image_capture/image_capture_frame_grabber.h"
57 #include "content/renderer/media/audio_decoder.h" 57 #include "content/renderer/media/audio_decoder.h"
58 #include "content/renderer/media/audio_device_factory.h" 58 #include "content/renderer/media/audio_device_factory.h"
59 #include "content/renderer/media/renderer_webaudiodevice_impl.h" 59 #include "content/renderer/media/renderer_webaudiodevice_impl.h"
60 #include "content/renderer/media/renderer_webmidiaccessor_impl.h" 60 #include "content/renderer/media/renderer_webmidiaccessor_impl.h"
61 #include "content/renderer/media_capture_from_element/canvas_capture_handler.h" 61 #include "content/renderer/media_capture_from_element/canvas_capture_handler.h"
62 #include "content/renderer/media_capture_from_element/html_audio_element_capture r_source.h" 62 #include "content/renderer/media_capture_from_element/html_audio_element_capture r_source.h"
63 #include "content/renderer/media_capture_from_element/html_video_element_capture r_source.h" 63 #include "content/renderer/media_capture_from_element/html_video_element_capture r_source.h"
64 #include "content/renderer/media_recorder/media_recorder_handler.h" 64 #include "content/renderer/media_recorder/media_recorder_handler.h"
65 #include "content/renderer/mojo/blink_interface_provider_impl.h" 65 #include "content/renderer/mojo/blink_interface_provider_impl.h"
66 #include "content/renderer/render_frame_impl.h"
67 #include "content/renderer/render_thread_impl.h" 66 #include "content/renderer/render_thread_impl.h"
68 #include "content/renderer/renderer_clipboard_delegate.h" 67 #include "content/renderer/renderer_clipboard_delegate.h"
69 #include "content/renderer/webclipboard_impl.h" 68 #include "content/renderer/webclipboard_impl.h"
70 #include "content/renderer/webgraphicscontext3d_provider_impl.h" 69 #include "content/renderer/webgraphicscontext3d_provider_impl.h"
71 #include "content/renderer/webpublicsuffixlist_impl.h" 70 #include "content/renderer/webpublicsuffixlist_impl.h"
72 #include "device/gamepad/public/cpp/gamepads.h" 71 #include "device/gamepad/public/cpp/gamepads.h"
73 #include "gpu/command_buffer/client/gles2_interface.h" 72 #include "gpu/command_buffer/client/gles2_interface.h"
74 #include "gpu/config/gpu_info.h" 73 #include "gpu/config/gpu_info.h"
75 #include "gpu/ipc/client/gpu_channel_host.h" 74 #include "gpu/ipc/client/gpu_channel_host.h"
76 #include "gpu/ipc/common/gpu_stream_constants.h" 75 #include "gpu/ipc/common/gpu_stream_constants.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 sandbox_support_.reset(); 300 sandbox_support_.reset();
302 #endif 301 #endif
303 } 302 }
304 303
305 //------------------------------------------------------------------------------ 304 //------------------------------------------------------------------------------
306 305
307 std::unique_ptr<blink::WebURLLoader> 306 std::unique_ptr<blink::WebURLLoader>
308 RendererBlinkPlatformImpl::CreateURLLoader() { 307 RendererBlinkPlatformImpl::CreateURLLoader() {
309 ChildThreadImpl* child_thread = ChildThreadImpl::current(); 308 ChildThreadImpl* child_thread = ChildThreadImpl::current();
310 309
311 const bool network_service_enabled = 310 mojom::URLLoaderFactory* factory =
312 base::CommandLine::ForCurrentProcess()->HasSwitch( 311 url_loader_factory_ ? url_loader_factory_.get()
313 switches::kEnableNetworkService); 312 : network_service_url_loader_factory_.get();
314 313 if (!factory && child_thread) {
315 mojom::URLLoaderFactory* factory = nullptr; 314 bool network_service_enabled =
316 if (!network_service_enabled) { 315 base::CommandLine::ForCurrentProcess()->HasSwitch(
317 if (child_thread) { 316 switches::kEnableNetworkService);
317 if (network_service_enabled) {
318 connector_->BindInterface(mojom::kNetworkServiceName,
319 &network_service_url_loader_factory_);
320 factory = network_service_url_loader_factory_.get();
321 } else {
318 child_thread->channel()->GetRemoteAssociatedInterface( 322 child_thread->channel()->GetRemoteAssociatedInterface(
319 &url_loader_factory_); 323 &url_loader_factory_);
320 } 324 factory = url_loader_factory_.get();
321 factory = url_loader_factory_.get();
322 } else {
323 // If there's a URLLoaderFactory attached to the frame, use it.
324 // TODO(yhirano|scottmg): Make the URLLoaderFactory always a per-frame
325 // thing? See https://crbug.com/712913.
326 blink::WebLocalFrame* const web_frame =
327 blink::WebLocalFrame::FrameForCurrentContext();
328 RenderFrameImpl* render_frame =
329 static_cast<RenderFrameImpl*>(RenderFrame::FromWebFrame(web_frame));
330 if (render_frame && render_frame->GetURLLoaderFactory()) {
331 factory = render_frame->GetURLLoaderFactory();
332 } else {
333 if (!network_service_url_loader_factory_) {
334 connector_->BindInterface(mojom::kNetworkServiceName,
335 &network_service_url_loader_factory_);
336 }
337 factory = network_service_url_loader_factory_.get();
338 } 325 }
339 } 326 }
340 327
341 // There may be no child thread in RenderViewTests. These tests can still use 328 // There may be no child thread in RenderViewTests. These tests can still use
342 // data URLs to bypass the ResourceDispatcher. 329 // data URLs to bypass the ResourceDispatcher.
343 return base::MakeUnique<WebURLLoaderImpl>( 330 return base::MakeUnique<WebURLLoaderImpl>(
344 child_thread ? child_thread->resource_dispatcher() : nullptr, factory); 331 child_thread ? child_thread->resource_dispatcher() : nullptr, factory);
345 } 332 }
346 333
347 blink::WebThread* RendererBlinkPlatformImpl::CurrentThread() { 334 blink::WebThread* RendererBlinkPlatformImpl::CurrentThread() {
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 //------------------------------------------------------------------------------ 1283 //------------------------------------------------------------------------------
1297 void RendererBlinkPlatformImpl::RequestPurgeMemory() { 1284 void RendererBlinkPlatformImpl::RequestPurgeMemory() {
1298 // TODO(tasak|bashi): We should use ChildMemoryCoordinator here, but 1285 // TODO(tasak|bashi): We should use ChildMemoryCoordinator here, but
1299 // ChildMemoryCoordinator isn't always available as it's only initialized 1286 // ChildMemoryCoordinator isn't always available as it's only initialized
1300 // when kMemoryCoordinatorV0 is enabled. 1287 // when kMemoryCoordinatorV0 is enabled.
1301 // Use ChildMemoryCoordinator when memory coordinator is always enabled. 1288 // Use ChildMemoryCoordinator when memory coordinator is always enabled.
1302 base::MemoryCoordinatorClientRegistry::GetInstance()->PurgeMemory(); 1289 base::MemoryCoordinatorClientRegistry::GetInstance()->PurgeMemory();
1303 } 1290 }
1304 1291
1305 } // namespace content 1292 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698