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 #include "headless/public/util/deterministic_http_protocol_handler.h" | 5 #include "headless/public/util/deterministic_http_protocol_handler.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "headless/public/headless_browser_context.h" | 9 #include "headless/public/headless_browser_context.h" |
10 #include "headless/public/util/deterministic_dispatcher.h" | 10 #include "headless/public/util/deterministic_dispatcher.h" |
11 #include "headless/public/util/generic_url_request_job.h" | 11 #include "headless/public/util/generic_url_request_job.h" |
12 #include "headless/public/util/http_url_fetcher.h" | 12 #include "headless/public/util/http_url_fetcher.h" |
13 #include "net/url_request/url_request_context.h" | 13 #include "net/url_request/url_request_context.h" |
14 #include "net/url_request/url_request_job_factory_impl.h" | 14 #include "net/url_request/url_request_job_factory_impl.h" |
15 | 15 |
16 namespace headless { | 16 namespace headless { |
17 | 17 |
18 class DeterministicHttpProtocolHandler::NopGenericURLRequestJobDelegate | 18 class DeterministicHttpProtocolHandler::NopGenericURLRequestJobDelegate |
19 : public GenericURLRequestJob::Delegate { | 19 : public GenericURLRequestJob::Delegate { |
20 public: | 20 public: |
21 NopGenericURLRequestJobDelegate() {} | 21 NopGenericURLRequestJobDelegate() {} |
22 ~NopGenericURLRequestJobDelegate() override {} | 22 ~NopGenericURLRequestJobDelegate() override {} |
23 | 23 |
24 // GenericURLRequestJob::Delegate methods: | 24 // GenericURLRequestJob::Delegate methods: |
25 bool BlockOrRewriteRequest( | 25 void OnPendingRequest(PendingRequest* pending_request) override { |
26 const GURL& url, | 26 pending_request->AllowRequest(); |
27 const std::string& devtools_id, | |
28 const std::string& method, | |
29 const std::string& referrer, | |
30 GenericURLRequestJob::RewriteCallback callback) override { | |
31 return false; | |
32 } | 27 } |
33 | 28 |
34 const GenericURLRequestJob::HttpResponse* MaybeMatchResource( | 29 void OnResourceLoadFailed(const Request* request, net::Error error) override { |
35 const GURL& url, | |
36 const std::string& devtools_id, | |
37 const std::string& method, | |
38 const net::HttpRequestHeaders& request_headers) override { | |
39 return nullptr; | |
40 } | 30 } |
41 | 31 |
42 void OnResourceLoadComplete(const GURL& final_url, | 32 void OnResourceLoadComplete( |
43 const std::string& devtools_id, | 33 const Request* request, |
44 const std::string& mime_type, | 34 const GURL& final_url, |
45 int http_response_code) override {} | 35 int http_response_code, |
| 36 scoped_refptr<net::HttpResponseHeaders> response_headers, |
| 37 const char* body, |
| 38 size_t body_size) override {} |
46 | 39 |
47 private: | 40 private: |
48 DISALLOW_COPY_AND_ASSIGN(NopGenericURLRequestJobDelegate); | 41 DISALLOW_COPY_AND_ASSIGN(NopGenericURLRequestJobDelegate); |
49 }; | 42 }; |
50 | 43 |
51 DeterministicHttpProtocolHandler::DeterministicHttpProtocolHandler( | 44 DeterministicHttpProtocolHandler::DeterministicHttpProtocolHandler( |
52 DeterministicDispatcher* deterministic_dispatcher, | 45 DeterministicDispatcher* deterministic_dispatcher, |
53 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) | 46 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) |
54 : deterministic_dispatcher_(deterministic_dispatcher), | 47 : deterministic_dispatcher_(deterministic_dispatcher), |
55 io_task_runner_(io_task_runner), | 48 io_task_runner_(io_task_runner), |
(...skipping 18 matching lines...) Expand all Loading... |
74 url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl()); | 67 url_request_job_factory_.reset(new net::URLRequestJobFactoryImpl()); |
75 url_request_context_->set_job_factory(url_request_job_factory_.get()); | 68 url_request_context_->set_job_factory(url_request_job_factory_.get()); |
76 } | 69 } |
77 return new GenericURLRequestJob( | 70 return new GenericURLRequestJob( |
78 request, network_delegate, deterministic_dispatcher_, | 71 request, network_delegate, deterministic_dispatcher_, |
79 base::MakeUnique<HttpURLFetcher>(url_request_context_.get()), | 72 base::MakeUnique<HttpURLFetcher>(url_request_context_.get()), |
80 nop_delegate_.get()); | 73 nop_delegate_.get()); |
81 } | 74 } |
82 | 75 |
83 } // namespace headless | 76 } // namespace headless |
OLD | NEW |