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 "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
11 #include "content/common/url_loader_factory.mojom.h" | 11 #include "content/common/url_loader_factory.mojom.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 class ResourceRequesterInfo; | 15 class ResourceRequesterInfo; |
16 | 16 |
17 // This class is an implementation of mojom::URLLoaderFactory that creates | 17 // This class is an implementation of mojom::URLLoaderFactory that creates |
18 // a mojom::URLLoader. This class is instantiated only for Service Worker | 18 // a mojom::URLLoader. This class is instantiated only for Service Worker |
19 // navigation preload or test caseses. | 19 // navigation preload or test caseses. |
20 class URLLoaderFactoryImpl final : public mojom::URLLoaderFactory { | 20 class URLLoaderFactoryImpl final : public mojom::URLLoaderFactory { |
21 public: | 21 public: |
22 ~URLLoaderFactoryImpl() override; | 22 ~URLLoaderFactoryImpl() override; |
23 | 23 |
24 void CreateLoaderAndStart( | 24 void CreateLoaderAndStart(mojom::URLLoaderAssociatedRequest request, |
25 mojom::URLLoaderAssociatedRequest request, | 25 int32_t routing_id, |
26 int32_t routing_id, | 26 int32_t request_id, |
27 int32_t request_id, | 27 const ResourceRequest& url_request, |
28 const ResourceRequest& url_request, | 28 mojom::URLLoaderClientPtr client) override; |
29 mojom::URLLoaderClientAssociatedPtrInfo client_ptr_info) override; | |
30 void SyncLoad(int32_t routing_id, | 29 void SyncLoad(int32_t routing_id, |
31 int32_t request_id, | 30 int32_t request_id, |
32 const ResourceRequest& request, | 31 const ResourceRequest& request, |
33 const SyncLoadCallback& callback) override; | 32 const SyncLoadCallback& callback) override; |
34 | 33 |
35 static void CreateLoaderAndStart( | 34 static void CreateLoaderAndStart(ResourceRequesterInfo* requester_info, |
36 ResourceRequesterInfo* requester_info, | 35 mojom::URLLoaderAssociatedRequest request, |
37 mojom::URLLoaderAssociatedRequest request, | 36 int32_t routing_id, |
38 int32_t routing_id, | 37 int32_t request_id, |
39 int32_t request_id, | 38 const ResourceRequest& url_request, |
40 const ResourceRequest& url_request, | 39 mojom::URLLoaderClientPtr client); |
41 mojom::URLLoaderClientAssociatedPtrInfo client_ptr_info); | |
42 static void SyncLoad(ResourceRequesterInfo* requester_info, | 40 static void SyncLoad(ResourceRequesterInfo* requester_info, |
43 int32_t routing_id, | 41 int32_t routing_id, |
44 int32_t request_id, | 42 int32_t request_id, |
45 const ResourceRequest& request, | 43 const ResourceRequest& request, |
46 const SyncLoadCallback& callback); | 44 const SyncLoadCallback& callback); |
47 | 45 |
48 // Creates a URLLoaderFactoryImpl instance. The instance is held by the | 46 // Creates a URLLoaderFactoryImpl instance. The instance is held by the |
49 // StrongBinding in it, so this function doesn't return the instance. | 47 // StrongBinding in it, so this function doesn't return the instance. |
50 CONTENT_EXPORT static void Create( | 48 CONTENT_EXPORT static void Create( |
51 scoped_refptr<ResourceRequesterInfo> requester_info, | 49 scoped_refptr<ResourceRequesterInfo> requester_info, |
52 mojom::URLLoaderFactoryRequest request); | 50 mojom::URLLoaderFactoryRequest request); |
53 | 51 |
54 private: | 52 private: |
55 explicit URLLoaderFactoryImpl( | 53 explicit URLLoaderFactoryImpl( |
56 scoped_refptr<ResourceRequesterInfo> requester_info); | 54 scoped_refptr<ResourceRequesterInfo> requester_info); |
57 | 55 |
58 scoped_refptr<ResourceRequesterInfo> requester_info_; | 56 scoped_refptr<ResourceRequesterInfo> requester_info_; |
59 | 57 |
60 DISALLOW_COPY_AND_ASSIGN(URLLoaderFactoryImpl); | 58 DISALLOW_COPY_AND_ASSIGN(URLLoaderFactoryImpl); |
61 }; | 59 }; |
62 | 60 |
63 } // namespace content | 61 } // namespace content |
64 | 62 |
65 #endif // CONTENT_BROWSER_LOADER_URL_LOADER_FACTORY_IMPL_H_ | 63 #endif // CONTENT_BROWSER_LOADER_URL_LOADER_FACTORY_IMPL_H_ |
OLD | NEW |