| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CONTENT_BROWSER_LOADER_URL_LOADER_FACTORY_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_LOADER_URL_LOADER_FACTORY_IMPL_H_ |
| 6 #define CONTENT_BROWSER_LOADER_URL_LOADER_FACTORY_IMPL_H_ | 6 #define CONTENT_BROWSER_LOADER_URL_LOADER_FACTORY_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
| 12 #include "content/common/url_loader_factory.mojom.h" | 12 #include "content/common/url_loader_factory.mojom.h" |
| 13 #include "net/traffic_annotation/network_traffic_annotation.h" |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 class ResourceRequesterInfo; | 17 class ResourceRequesterInfo; |
| 17 | 18 |
| 18 // This class is an implementation of mojom::URLLoaderFactory that creates | 19 // This class is an implementation of mojom::URLLoaderFactory that creates |
| 19 // a mojom::URLLoader. This class is instantiated only for Service Worker | 20 // a mojom::URLLoader. This class is instantiated only for Service Worker |
| 20 // navigation preload or test caseses. | 21 // navigation preload or test caseses. |
| 21 class URLLoaderFactoryImpl final : public mojom::URLLoaderFactory { | 22 class URLLoaderFactoryImpl final : public mojom::URLLoaderFactory { |
| 22 public: | 23 public: |
| 23 ~URLLoaderFactoryImpl() override; | 24 ~URLLoaderFactoryImpl() override; |
| 24 | 25 |
| 25 void CreateLoaderAndStart(mojom::URLLoaderAssociatedRequest request, | 26 void CreateLoaderAndStart(mojom::URLLoaderAssociatedRequest request, |
| 26 int32_t routing_id, | 27 int32_t routing_id, |
| 27 int32_t request_id, | 28 int32_t request_id, |
| 28 uint32_t options, | 29 uint32_t options, |
| 29 const ResourceRequest& url_request, | 30 const ResourceRequest& url_request, |
| 30 mojom::URLLoaderClientPtr client) override; | 31 mojom::URLLoaderClientPtr client, |
| 32 const net::MutableNetworkTrafficAnnotationTag& |
| 33 traffic_annotation) override; |
| 31 void SyncLoad(int32_t routing_id, | 34 void SyncLoad(int32_t routing_id, |
| 32 int32_t request_id, | 35 int32_t request_id, |
| 33 const ResourceRequest& request, | 36 const ResourceRequest& request, |
| 34 SyncLoadCallback callback) override; | 37 SyncLoadCallback callback) override; |
| 35 | 38 |
| 36 static void CreateLoaderAndStart(ResourceRequesterInfo* requester_info, | 39 static void CreateLoaderAndStart( |
| 37 mojom::URLLoaderAssociatedRequest request, | 40 ResourceRequesterInfo* requester_info, |
| 38 int32_t routing_id, | 41 mojom::URLLoaderAssociatedRequest request, |
| 39 int32_t request_id, | 42 int32_t routing_id, |
| 40 const ResourceRequest& url_request, | 43 int32_t request_id, |
| 41 mojom::URLLoaderClientPtr client); | 44 const ResourceRequest& url_request, |
| 45 mojom::URLLoaderClientPtr client, |
| 46 const net::NetworkTrafficAnnotationTag& traffic_annotation); |
| 47 |
| 42 static void SyncLoad(ResourceRequesterInfo* requester_info, | 48 static void SyncLoad(ResourceRequesterInfo* requester_info, |
| 43 int32_t routing_id, | 49 int32_t routing_id, |
| 44 int32_t request_id, | 50 int32_t request_id, |
| 45 const ResourceRequest& request, | 51 const ResourceRequest& request, |
| 46 SyncLoadCallback callback); | 52 SyncLoadCallback callback); |
| 47 | 53 |
| 48 // Creates a URLLoaderFactoryImpl instance. The instance is held by the | 54 // Creates a URLLoaderFactoryImpl instance. The instance is held by the |
| 49 // StrongBinding in it, so this function doesn't return the instance. | 55 // StrongBinding in it, so this function doesn't return the instance. |
| 50 CONTENT_EXPORT static void Create( | 56 CONTENT_EXPORT static void Create( |
| 51 scoped_refptr<ResourceRequesterInfo> requester_info, | 57 scoped_refptr<ResourceRequesterInfo> requester_info, |
| 52 mojom::URLLoaderFactoryRequest request, | 58 mojom::URLLoaderFactoryRequest request, |
| 53 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_runner); | 59 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_runner); |
| 54 | 60 |
| 55 private: | 61 private: |
| 56 explicit URLLoaderFactoryImpl( | 62 explicit URLLoaderFactoryImpl( |
| 57 scoped_refptr<ResourceRequesterInfo> requester_info, | 63 scoped_refptr<ResourceRequesterInfo> requester_info, |
| 58 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_runner); | 64 const scoped_refptr<base::SingleThreadTaskRunner>& io_thread_runner); |
| 59 | 65 |
| 60 scoped_refptr<ResourceRequesterInfo> requester_info_; | 66 scoped_refptr<ResourceRequesterInfo> requester_info_; |
| 61 | 67 |
| 62 // Task runner for the IO thead. | 68 // Task runner for the IO thead. |
| 63 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_; | 69 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner_; |
| 64 | 70 |
| 65 DISALLOW_COPY_AND_ASSIGN(URLLoaderFactoryImpl); | 71 DISALLOW_COPY_AND_ASSIGN(URLLoaderFactoryImpl); |
| 66 }; | 72 }; |
| 67 | 73 |
| 68 } // namespace content | 74 } // namespace content |
| 69 | 75 |
| 70 #endif // CONTENT_BROWSER_LOADER_URL_LOADER_FACTORY_IMPL_H_ | 76 #endif // CONTENT_BROWSER_LOADER_URL_LOADER_FACTORY_IMPL_H_ |
| OLD | NEW |