OLD | NEW |
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ |
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ | 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "content/browser/appcache/appcache_entry.h" | 13 #include "content/browser/appcache/appcache_entry.h" |
14 #include "content/browser/appcache/appcache_job.h" | 14 #include "content/browser/appcache/appcache_job.h" |
| 15 #include "content/browser/appcache/appcache_request_handler.h" |
15 #include "content/browser/appcache/appcache_response.h" | 16 #include "content/browser/appcache/appcache_response.h" |
16 #include "content/browser/appcache/appcache_storage.h" | 17 #include "content/browser/appcache/appcache_storage.h" |
17 #include "content/browser/loader/url_loader_request_handler.h" | 18 #include "content/browser/loader/url_loader_request_handler.h" |
18 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
19 #include "content/common/resource_request.h" | 20 #include "content/common/resource_request.h" |
20 #include "content/common/url_loader.mojom.h" | 21 #include "content/common/url_loader.mojom.h" |
| 22 #include "mojo/public/cpp/bindings/associated_binding.h" |
21 #include "mojo/public/cpp/bindings/binding.h" | 23 #include "mojo/public/cpp/bindings/binding.h" |
22 #include "mojo/public/cpp/system/data_pipe.h" | 24 #include "mojo/public/cpp/system/data_pipe.h" |
23 | 25 |
24 namespace content { | 26 namespace content { |
25 | 27 |
26 class AppCacheRequest; | 28 class AppCacheRequest; |
27 class NetToMojoPendingBuffer; | 29 class NetToMojoPendingBuffer; |
| 30 class URLLoaderFactoryGetter; |
| 31 struct SubresourceLoadInfo; |
28 | 32 |
29 // AppCacheJob wrapper for a mojom::URLLoader implementation which returns | 33 // AppCacheJob wrapper for a mojom::URLLoader implementation which returns |
30 // responses stored in the AppCache. | 34 // responses stored in the AppCache. |
31 class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob, | 35 class CONTENT_EXPORT AppCacheURLLoaderJob : public AppCacheJob, |
32 public AppCacheStorage::Delegate, | 36 public AppCacheStorage::Delegate, |
33 public mojom::URLLoader { | 37 public mojom::URLLoader { |
34 public: | 38 public: |
35 ~AppCacheURLLoaderJob() override; | 39 ~AppCacheURLLoaderJob() override; |
36 | 40 |
37 // Sets up the bindings. | 41 // Sets up the bindings. |
(...skipping 13 matching lines...) Expand all Loading... |
51 | 55 |
52 // mojom::URLLoader implementation: | 56 // mojom::URLLoader implementation: |
53 void FollowRedirect() override; | 57 void FollowRedirect() override; |
54 void SetPriority(net::RequestPriority priority, | 58 void SetPriority(net::RequestPriority priority, |
55 int32_t intra_priority_value) override; | 59 int32_t intra_priority_value) override; |
56 | 60 |
57 void set_loader_callback(LoaderCallback callback) { | 61 void set_loader_callback(LoaderCallback callback) { |
58 loader_callback_ = std::move(callback); | 62 loader_callback_ = std::move(callback); |
59 } | 63 } |
60 | 64 |
| 65 // Subresource request load information is passed in the |
| 66 // |subresource_load_info| parameter. This includes the request id, the |
| 67 // client pointer, etc. |
| 68 // |handler| points to the AppCacheRequestHandler instance handling this |
| 69 // request. The job controls the lifetime of the handler. |
| 70 // |default_url_loader| is used to retrieve the network loader for requests |
| 71 // intended to be sent to the network. |
| 72 void SetSubresourceLoadInfo( |
| 73 std::unique_ptr<SubresourceLoadInfo> subresource_load_info, |
| 74 AppCacheRequestHandler* handler, |
| 75 URLLoaderFactoryGetter* default_url_loader); |
| 76 |
61 protected: | 77 protected: |
62 // AppCacheJob::Create() creates this instance. | 78 // AppCacheJob::Create() creates this instance. |
63 friend class AppCacheJob; | 79 friend class AppCacheJob; |
64 | 80 |
65 AppCacheURLLoaderJob(const ResourceRequest& request, | 81 AppCacheURLLoaderJob(const ResourceRequest& request, |
66 AppCacheStorage* storage); | 82 AppCacheStorage* storage); |
67 | 83 |
68 // AppCacheStorage::Delegate methods | 84 // AppCacheStorage::Delegate methods |
69 void OnResponseInfoLoaded(AppCacheResponseInfo* response_info, | 85 void OnResponseInfoLoaded(AppCacheResponseInfo* response_info, |
70 int64_t response_id) override; | 86 int64_t response_id) override; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 mojo::ScopedDataPipeProducerHandle response_body_stream_; | 135 mojo::ScopedDataPipeProducerHandle response_body_stream_; |
120 | 136 |
121 scoped_refptr<NetToMojoPendingBuffer> pending_write_; | 137 scoped_refptr<NetToMojoPendingBuffer> pending_write_; |
122 | 138 |
123 mojo::SimpleWatcher writable_handle_watcher_; | 139 mojo::SimpleWatcher writable_handle_watcher_; |
124 | 140 |
125 // The Callback to be invoked in the network service land to indicate if | 141 // The Callback to be invoked in the network service land to indicate if |
126 // the request can be serviced via the AppCache. | 142 // the request can be serviced via the AppCache. |
127 LoaderCallback loader_callback_; | 143 LoaderCallback loader_callback_; |
128 | 144 |
| 145 // We own the AppCacheRequestHandler instance for subresource requests. |
| 146 std::unique_ptr<AppCacheRequestHandler> handler_; |
| 147 |
| 148 scoped_refptr<URLLoaderFactoryGetter> default_url_loader_factory_getter_; |
| 149 |
| 150 // Holds subresource url loader information. |
| 151 std::unique_ptr<SubresourceLoadInfo> subresource_load_info_; |
| 152 |
| 153 // Timing information for the most recent request. Its start times are |
| 154 // populated in DeliverAppCachedResponse(). |
| 155 net::LoadTimingInfo load_timing_info_; |
| 156 |
| 157 // Used for subresource requests which go to the network. |
| 158 mojom::URLLoaderAssociatedPtr network_loader_request_; |
| 159 |
| 160 // Binds the subresource URLLoaderClient with us. We can use the regular |
| 161 // binding_ member above when we remove the need for the associated requests |
| 162 // issue with URLLoaderFactory. |
| 163 std::unique_ptr<mojo::AssociatedBinding<mojom::URLLoader>> |
| 164 associated_binding_; |
| 165 |
129 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderJob); | 166 DISALLOW_COPY_AND_ASSIGN(AppCacheURLLoaderJob); |
130 }; | 167 }; |
131 | 168 |
132 } // namespace content | 169 } // namespace content |
133 | 170 |
134 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ | 171 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_URL_LOADER_JOB_H_ |
OLD | NEW |