| 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_DETERMINISTIC_HTTP_PROTOCOL_HANDLER_H_ | 5 #ifndef HEADLESS_PUBLIC_UTIL_DETERMINISTIC_HTTP_PROTOCOL_HANDLER_H_ |
| 6 #define HEADLESS_PUBLIC_UTIL_DETERMINISTIC_HTTP_PROTOCOL_HANDLER_H_ | 6 #define HEADLESS_PUBLIC_UTIL_DETERMINISTIC_HTTP_PROTOCOL_HANDLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "headless/public/headless_export.h" |
| 11 #include "net/url_request/url_request_job_factory.h" | 12 #include "net/url_request/url_request_job_factory.h" |
| 12 | 13 |
| 13 namespace net { | 14 namespace net { |
| 14 class URLRequestContext; | 15 class URLRequestContext; |
| 15 class URLRequestJobFactory; | 16 class URLRequestJobFactory; |
| 16 } // namespace | 17 } // namespace |
| 17 | 18 |
| 18 namespace headless { | 19 namespace headless { |
| 19 class DeterministicDispatcher; | 20 class DeterministicDispatcher; |
| 20 | 21 |
| 21 // A deterministic protocol handler. Requests made to this protocol handler | 22 // A deterministic protocol handler. Requests made to this protocol handler |
| 22 // will return in order of creation, regardless of what order the network | 23 // will return in order of creation, regardless of what order the network |
| 23 // returns them in. This helps remove one large source of network related | 24 // returns them in. This helps remove one large source of network related |
| 24 // non determinism at the cost of slower page loads. | 25 // non determinism at the cost of slower page loads. |
| 25 class DeterministicHttpProtocolHandler | 26 class HEADLESS_EXPORT DeterministicHttpProtocolHandler |
| 26 : public net::URLRequestJobFactory::ProtocolHandler { | 27 : public net::URLRequestJobFactory::ProtocolHandler { |
| 27 public: | 28 public: |
| 28 // Note |deterministic_dispatcher| is expected to be shared across a number of | 29 // Note |deterministic_dispatcher| is expected to be shared across a number of |
| 29 // protocol handlers, e.g. for http & https protocols. | 30 // protocol handlers, e.g. for http & https protocols. |
| 30 DeterministicHttpProtocolHandler( | 31 DeterministicHttpProtocolHandler( |
| 31 DeterministicDispatcher* deterministic_dispatcher, | 32 DeterministicDispatcher* deterministic_dispatcher, |
| 32 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); | 33 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); |
| 33 ~DeterministicHttpProtocolHandler() override; | 34 ~DeterministicHttpProtocolHandler() override; |
| 34 | 35 |
| 35 net::URLRequestJob* MaybeCreateJob( | 36 net::URLRequestJob* MaybeCreateJob( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 49 // http resources. | 50 // http resources. |
| 50 mutable std::unique_ptr<net::URLRequestContext> url_request_context_; | 51 mutable std::unique_ptr<net::URLRequestContext> url_request_context_; |
| 51 mutable std::unique_ptr<net::URLRequestJobFactory> url_request_job_factory_; | 52 mutable std::unique_ptr<net::URLRequestJobFactory> url_request_job_factory_; |
| 52 | 53 |
| 53 DISALLOW_COPY_AND_ASSIGN(DeterministicHttpProtocolHandler); | 54 DISALLOW_COPY_AND_ASSIGN(DeterministicHttpProtocolHandler); |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 } // namespace headless | 57 } // namespace headless |
| 57 | 58 |
| 58 #endif // HEADLESS_PUBLIC_UTIL_DETERMINISTIC_HTTP_PROTOCOL_HANDLER_H_ | 59 #endif // HEADLESS_PUBLIC_UTIL_DETERMINISTIC_HTTP_PROTOCOL_HANDLER_H_ |
| OLD | NEW |