OLD | NEW |
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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 sandbox_support_.reset(); | 297 sandbox_support_.reset(); |
298 #endif | 298 #endif |
299 } | 299 } |
300 | 300 |
301 //------------------------------------------------------------------------------ | 301 //------------------------------------------------------------------------------ |
302 | 302 |
303 std::unique_ptr<blink::WebURLLoader> | 303 std::unique_ptr<blink::WebURLLoader> |
304 RendererBlinkPlatformImpl::CreateURLLoader() { | 304 RendererBlinkPlatformImpl::CreateURLLoader() { |
305 ChildThreadImpl* child_thread = ChildThreadImpl::current(); | 305 ChildThreadImpl* child_thread = ChildThreadImpl::current(); |
306 | 306 |
307 mojom::URLLoaderFactory* factory = | 307 if (!url_loader_factory_ && child_thread) { |
308 url_loader_factory_ ? url_loader_factory_.get() | |
309 : network_service_url_loader_factory_.get(); | |
310 if (!factory && child_thread) { | |
311 bool network_service_enabled = | 308 bool network_service_enabled = |
312 base::CommandLine::ForCurrentProcess()->HasSwitch( | 309 base::CommandLine::ForCurrentProcess()->HasSwitch( |
313 switches::kEnableNetworkService); | 310 switches::kEnableNetworkService); |
314 if (network_service_enabled) { | 311 if (network_service_enabled) { |
315 connector_->BindInterface(mojom::kNetworkServiceName, | 312 mojom::URLLoaderFactoryPtr factory_ptr; |
316 &network_service_url_loader_factory_); | 313 connector_->BindInterface(mojom::kNetworkServiceName, &factory_ptr); |
317 factory = network_service_url_loader_factory_.get(); | 314 url_loader_factory_ = std::move(factory_ptr); |
318 } else { | 315 } else { |
319 child_thread->channel()->GetRemoteAssociatedInterface( | 316 mojom::URLLoaderFactoryAssociatedPtr factory_ptr; |
320 &url_loader_factory_); | 317 child_thread->channel()->GetRemoteAssociatedInterface(&factory_ptr); |
321 factory = url_loader_factory_.get(); | 318 url_loader_factory_ = std::move(factory_ptr); |
322 } | 319 } |
323 } | 320 } |
324 | 321 |
325 // There may be no child thread in RenderViewTests. These tests can still use | 322 // There may be no child thread in RenderViewTests. These tests can still use |
326 // data URLs to bypass the ResourceDispatcher. | 323 // data URLs to bypass the ResourceDispatcher. |
327 return base::MakeUnique<WebURLLoaderImpl>( | 324 return base::MakeUnique<WebURLLoaderImpl>( |
328 child_thread ? child_thread->resource_dispatcher() : nullptr, factory); | 325 child_thread ? child_thread->resource_dispatcher() : nullptr, |
| 326 url_loader_factory_.get()); |
329 } | 327 } |
330 | 328 |
331 blink::WebThread* RendererBlinkPlatformImpl::CurrentThread() { | 329 blink::WebThread* RendererBlinkPlatformImpl::CurrentThread() { |
332 if (main_thread_->IsCurrentThread()) | 330 if (main_thread_->IsCurrentThread()) |
333 return main_thread_.get(); | 331 return main_thread_.get(); |
334 return BlinkPlatformImpl::CurrentThread(); | 332 return BlinkPlatformImpl::CurrentThread(); |
335 } | 333 } |
336 | 334 |
337 blink::BlameContext* RendererBlinkPlatformImpl::GetTopLevelBlameContext() { | 335 blink::BlameContext* RendererBlinkPlatformImpl::GetTopLevelBlameContext() { |
338 return &top_level_blame_context_; | 336 return &top_level_blame_context_; |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1273 //------------------------------------------------------------------------------ | 1271 //------------------------------------------------------------------------------ |
1274 void RendererBlinkPlatformImpl::RequestPurgeMemory() { | 1272 void RendererBlinkPlatformImpl::RequestPurgeMemory() { |
1275 // TODO(tasak|bashi): We should use ChildMemoryCoordinator here, but | 1273 // TODO(tasak|bashi): We should use ChildMemoryCoordinator here, but |
1276 // ChildMemoryCoordinator isn't always available as it's only initialized | 1274 // ChildMemoryCoordinator isn't always available as it's only initialized |
1277 // when kMemoryCoordinatorV0 is enabled. | 1275 // when kMemoryCoordinatorV0 is enabled. |
1278 // Use ChildMemoryCoordinator when memory coordinator is always enabled. | 1276 // Use ChildMemoryCoordinator when memory coordinator is always enabled. |
1279 base::MemoryCoordinatorClientRegistry::GetInstance()->PurgeMemory(); | 1277 base::MemoryCoordinatorClientRegistry::GetInstance()->PurgeMemory(); |
1280 } | 1278 } |
1281 | 1279 |
1282 } // namespace content | 1280 } // namespace content |
OLD | NEW |