| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/loader/navigation_url_loader.h" | 5 #include "content/browser/loader/navigation_url_loader.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "content/browser/frame_host/navigation_request_info.h" | 11 #include "content/browser/frame_host/navigation_request_info.h" |
| 12 #include "content/browser/loader/navigation_url_loader_factory.h" | 12 #include "content/browser/loader/navigation_url_loader_factory.h" |
| 13 #include "content/browser/loader/navigation_url_loader_impl.h" | 13 #include "content/browser/loader/navigation_url_loader_impl.h" |
| 14 #include "content/browser/loader/navigation_url_loader_network_service.h" | 14 #include "content/browser/loader/navigation_url_loader_network_service.h" |
| 15 #include "content/public/browser/navigation_ui_data.h" | 15 #include "content/public/browser/navigation_ui_data.h" |
| 16 #include "content/public/common/content_features.h" | 16 #include "content/public/common/content_features.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 static NavigationURLLoaderFactory* g_factory = nullptr; | 20 static NavigationURLLoaderFactory* g_loader_factory = nullptr; |
| 21 | 21 |
| 22 std::unique_ptr<NavigationURLLoader> NavigationURLLoader::Create( | 22 std::unique_ptr<NavigationURLLoader> NavigationURLLoader::Create( |
| 23 ResourceContext* resource_context, | 23 ResourceContext* resource_context, |
| 24 StoragePartition* storage_partition, | 24 StoragePartition* storage_partition, |
| 25 std::unique_ptr<NavigationRequestInfo> request_info, | 25 std::unique_ptr<NavigationRequestInfo> request_info, |
| 26 std::unique_ptr<NavigationUIData> navigation_ui_data, | 26 std::unique_ptr<NavigationUIData> navigation_ui_data, |
| 27 ServiceWorkerNavigationHandle* service_worker_handle, | 27 ServiceWorkerNavigationHandle* service_worker_handle, |
| 28 AppCacheNavigationHandle* appcache_handle, | 28 AppCacheNavigationHandle* appcache_handle, |
| 29 NavigationURLLoaderDelegate* delegate) { | 29 NavigationURLLoaderDelegate* delegate) { |
| 30 if (g_factory) { | 30 if (g_loader_factory) { |
| 31 return g_factory->CreateLoader( | 31 return g_loader_factory->CreateLoader( |
| 32 resource_context, storage_partition, std::move(request_info), | 32 resource_context, storage_partition, std::move(request_info), |
| 33 std::move(navigation_ui_data), service_worker_handle, delegate); | 33 std::move(navigation_ui_data), service_worker_handle, delegate); |
| 34 } | 34 } |
| 35 if (base::FeatureList::IsEnabled(features::kNetworkService)) { | 35 if (base::FeatureList::IsEnabled(features::kNetworkService)) { |
| 36 return base::MakeUnique<NavigationURLLoaderNetworkService>( | 36 return base::MakeUnique<NavigationURLLoaderNetworkService>( |
| 37 resource_context, storage_partition, std::move(request_info), | 37 resource_context, storage_partition, std::move(request_info), |
| 38 std::move(navigation_ui_data), service_worker_handle, appcache_handle, | 38 std::move(navigation_ui_data), service_worker_handle, appcache_handle, |
| 39 delegate); | 39 delegate); |
| 40 } else { | 40 } else { |
| 41 return base::MakeUnique<NavigationURLLoaderImpl>( | 41 return base::MakeUnique<NavigationURLLoaderImpl>( |
| 42 resource_context, storage_partition, std::move(request_info), | 42 resource_context, storage_partition, std::move(request_info), |
| 43 std::move(navigation_ui_data), service_worker_handle, appcache_handle, | 43 std::move(navigation_ui_data), service_worker_handle, appcache_handle, |
| 44 delegate); | 44 delegate); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 void NavigationURLLoader::SetFactoryForTesting( | 48 void NavigationURLLoader::SetFactoryForTesting( |
| 49 NavigationURLLoaderFactory* factory) { | 49 NavigationURLLoaderFactory* factory) { |
| 50 DCHECK(g_factory == nullptr || factory == nullptr); | 50 DCHECK(g_loader_factory == nullptr || factory == nullptr); |
| 51 g_factory = factory; | 51 g_loader_factory = factory; |
| 52 } | 52 } |
| 53 | 53 |
| 54 } // namespace content | 54 } // namespace content |
| OLD | NEW |