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 HEADLESS_PUBLIC_UTIL_GENERIC_URL_REQUEST_JOB_H_ | 5 #ifndef HEADLESS_PUBLIC_UTIL_GENERIC_URL_REQUEST_JOB_H_ |
6 #define HEADLESS_PUBLIC_UTIL_GENERIC_URL_REQUEST_JOB_H_ | 6 #define HEADLESS_PUBLIC_UTIL_GENERIC_URL_REQUEST_JOB_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <functional> | 9 #include <functional> |
10 #include <memory> | 10 #include <memory> |
(...skipping 18 matching lines...) Expand all Loading... |
29 class ResourceRequestInfo; | 29 class ResourceRequestInfo; |
30 } // namespace content | 30 } // namespace content |
31 | 31 |
32 namespace headless { | 32 namespace headless { |
33 | 33 |
34 class URLRequestDispatcher; | 34 class URLRequestDispatcher; |
35 | 35 |
36 // Wrapper around net::URLRequest with helpers to access select metadata. | 36 // Wrapper around net::URLRequest with helpers to access select metadata. |
37 class Request { | 37 class Request { |
38 public: | 38 public: |
| 39 virtual uint64_t GetRequestId() const = 0; |
| 40 |
39 virtual const net::URLRequest* GetURLRequest() const = 0; | 41 virtual const net::URLRequest* GetURLRequest() const = 0; |
40 | 42 |
41 // The frame from which the request came from. | 43 // The frame from which the request came from. |
42 virtual int GetFrameTreeNodeId() const = 0; | 44 virtual int GetFrameTreeNodeId() const = 0; |
43 | 45 |
44 // The devtools agent host id for the page where the request came from. | 46 // The devtools agent host id for the page where the request came from. |
45 virtual std::string GetDevToolsAgentHostId() const = 0; | 47 virtual std::string GetDevToolsAgentHostId() const = 0; |
46 | 48 |
| 49 // Gets the POST data, if any, from the net::URLRequest. |
| 50 virtual std::string GetPostData() const = 0; |
| 51 |
47 enum class ResourceType { | 52 enum class ResourceType { |
48 MAIN_FRAME = 0, | 53 MAIN_FRAME = 0, |
49 SUB_FRAME = 1, | 54 SUB_FRAME = 1, |
50 STYLESHEET = 2, | 55 STYLESHEET = 2, |
51 SCRIPT = 3, | 56 SCRIPT = 3, |
52 IMAGE = 4, | 57 IMAGE = 4, |
53 FONT_RESOURCE = 5, | 58 FONT_RESOURCE = 5, |
54 SUB_RESOURCE = 6, | 59 SUB_RESOURCE = 6, |
55 OBJECT = 7, | 60 OBJECT = 7, |
56 MEDIA = 8, | 61 MEDIA = 8, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 // URLFetcher::FetchResultListener implementation: | 176 // URLFetcher::FetchResultListener implementation: |
172 void OnFetchStartError(net::Error error) override; | 177 void OnFetchStartError(net::Error error) override; |
173 void OnFetchComplete(const GURL& final_url, | 178 void OnFetchComplete(const GURL& final_url, |
174 int http_response_code, | 179 int http_response_code, |
175 scoped_refptr<net::HttpResponseHeaders> response_headers, | 180 scoped_refptr<net::HttpResponseHeaders> response_headers, |
176 const char* body, | 181 const char* body, |
177 size_t body_size) override; | 182 size_t body_size) override; |
178 | 183 |
179 protected: | 184 protected: |
180 // Request implementation: | 185 // Request implementation: |
| 186 uint64_t GetRequestId() const override; |
181 const net::URLRequest* GetURLRequest() const override; | 187 const net::URLRequest* GetURLRequest() const override; |
182 int GetFrameTreeNodeId() const override; | 188 int GetFrameTreeNodeId() const override; |
183 std::string GetDevToolsAgentHostId() const override; | 189 std::string GetDevToolsAgentHostId() const override; |
| 190 std::string GetPostData() const override; |
184 ResourceType GetResourceType() const override; | 191 ResourceType GetResourceType() const override; |
185 | 192 |
186 // PendingRequest implementation: | 193 // PendingRequest implementation: |
187 const Request* GetRequest() const override; | 194 const Request* GetRequest() const override; |
188 void AllowRequest() override; | 195 void AllowRequest() override; |
189 void BlockRequest(net::Error error) override; | 196 void BlockRequest(net::Error error) override; |
190 void ModifyRequest(const GURL& url, | 197 void ModifyRequest(const GURL& url, |
191 const std::string& method, | 198 const std::string& method, |
192 const std::string& post_data, | 199 const std::string& post_data, |
193 const net::HttpRequestHeaders& request_headers) override; | 200 const net::HttpRequestHeaders& request_headers) override; |
(...skipping 14 matching lines...) Expand all Loading... |
208 scoped_refptr<net::HttpResponseHeaders> response_headers_; | 215 scoped_refptr<net::HttpResponseHeaders> response_headers_; |
209 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_; | 216 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_; |
210 std::unique_ptr<MockResponseData> mock_response_; | 217 std::unique_ptr<MockResponseData> mock_response_; |
211 Delegate* delegate_; // Not owned. | 218 Delegate* delegate_; // Not owned. |
212 const content::ResourceRequestInfo* request_resource_info_; // Not owned. | 219 const content::ResourceRequestInfo* request_resource_info_; // Not owned. |
213 const char* body_ = nullptr; // Not owned. | 220 const char* body_ = nullptr; // Not owned. |
214 int http_response_code_ = 0; | 221 int http_response_code_ = 0; |
215 size_t body_size_ = 0; | 222 size_t body_size_ = 0; |
216 size_t read_offset_ = 0; | 223 size_t read_offset_ = 0; |
217 base::TimeTicks response_time_; | 224 base::TimeTicks response_time_; |
| 225 const uint64_t request_id_; |
| 226 static uint64_t next_request_id_; |
218 | 227 |
219 base::WeakPtrFactory<GenericURLRequestJob> weak_factory_; | 228 base::WeakPtrFactory<GenericURLRequestJob> weak_factory_; |
220 | 229 |
221 DISALLOW_COPY_AND_ASSIGN(GenericURLRequestJob); | 230 DISALLOW_COPY_AND_ASSIGN(GenericURLRequestJob); |
222 }; | 231 }; |
223 | 232 |
224 } // namespace headless | 233 } // namespace headless |
225 | 234 |
226 #endif // HEADLESS_PUBLIC_UTIL_GENERIC_URL_REQUEST_JOB_H_ | 235 #endif // HEADLESS_PUBLIC_UTIL_GENERIC_URL_REQUEST_JOB_H_ |
OLD | NEW |