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_switches.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_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_factory) { |
31 return g_factory->CreateLoader( | 31 return g_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::CommandLine::ForCurrentProcess()->HasSwitch( | 35 if (base::FeatureList::IsEnabled(features::kNetworkService)) { |
36 switches::kEnableNetworkService)) { | |
37 return base::MakeUnique<NavigationURLLoaderNetworkService>( | 36 return base::MakeUnique<NavigationURLLoaderNetworkService>( |
38 resource_context, storage_partition, std::move(request_info), | 37 resource_context, storage_partition, std::move(request_info), |
39 std::move(navigation_ui_data), service_worker_handle, appcache_handle, | 38 std::move(navigation_ui_data), service_worker_handle, appcache_handle, |
40 delegate); | 39 delegate); |
41 } else { | 40 } else { |
42 return base::MakeUnique<NavigationURLLoaderImpl>( | 41 return base::MakeUnique<NavigationURLLoaderImpl>( |
43 resource_context, storage_partition, std::move(request_info), | 42 resource_context, storage_partition, std::move(request_info), |
44 std::move(navigation_ui_data), service_worker_handle, appcache_handle, | 43 std::move(navigation_ui_data), service_worker_handle, appcache_handle, |
45 delegate); | 44 delegate); |
46 } | 45 } |
47 } | 46 } |
48 | 47 |
49 void NavigationURLLoader::SetFactoryForTesting( | 48 void NavigationURLLoader::SetFactoryForTesting( |
50 NavigationURLLoaderFactory* factory) { | 49 NavigationURLLoaderFactory* factory) { |
51 DCHECK(g_factory == nullptr || factory == nullptr); | 50 DCHECK(g_factory == nullptr || factory == nullptr); |
52 g_factory = factory; | 51 g_factory = factory; |
53 } | 52 } |
54 | 53 |
55 } // namespace content | 54 } // namespace content |
OLD | NEW |