Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef HEADLESS_PUBLIC_UTIL_DETERMINISTIC_HTTP_PROTOCOL_HANDLER_H_ | |
| 6 #define HEADLESS_PUBLIC_UTIL_DETERMINISTIC_HTTP_PROTOCOL_HANDLER_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/single_thread_task_runner.h" | |
| 11 #include "net/url_request/url_request_job_factory.h" | |
| 12 | |
| 13 namespace net { | |
| 14 class URLRequestContext; | |
| 15 class URLRequestJobFactory; | |
| 16 } // namespace | |
| 17 | |
| 18 namespace headless { | |
| 19 class DeterministicDispatcher; | |
| 20 class HeadlessBrowserContext; | |
| 21 | |
| 22 // A deterministic protocol handler. Requests make to this protocol handler | |
|
Sami
2016/09/23 14:27:29
s/make/made/
alex clarke (OOO till 29th)
2016/09/23 16:40:26
Done.
| |
| 23 // will return in order of creation, regardless of what order the network | |
| 24 // returns them in. This helps remove one large source of network related | |
| 25 // non determinism at the cost of slower page loads. | |
| 26 class DeterministicHttpProtocolHandler | |
| 27 : public net::URLRequestJobFactory::ProtocolHandler { | |
| 28 public: | |
| 29 // Note |deterministic_dispatcher| is expected to be shared across a number of | |
| 30 // protocol handlers, e.g. for http & https protocols. | |
| 31 DeterministicHttpProtocolHandler( | |
| 32 DeterministicDispatcher* deterministic_dispatcher, | |
| 33 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); | |
| 34 ~DeterministicHttpProtocolHandler() override; | |
| 35 | |
| 36 net::URLRequestJob* MaybeCreateJob( | |
| 37 net::URLRequest* request, | |
| 38 net::NetworkDelegate* network_delegate) const override; | |
| 39 | |
| 40 private: | |
| 41 class NopGenericURLRequestJobDelegate; | |
| 42 | |
| 43 DeterministicDispatcher* deterministic_dispatcher_; // NOT OWNED. | |
| 44 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | |
| 45 std::unique_ptr<NopGenericURLRequestJobDelegate> nop_delagate_; | |
| 46 | |
| 47 // |url_request_context_| and |url_request_job_factory_| are lazily created on | |
| 48 // the IO thread. The URLRequestContextis setup to bypassing any | |
|
Sami
2016/09/23 14:27:29
s/Contextis/Context is/
alex clarke (OOO till 29th)
2016/09/23 16:40:26
Done.
| |
| 49 // user-specified protocol handlers including this one. This is necessary to | |
| 50 // actually fetch http resources. | |
| 51 mutable std::unique_ptr<net::URLRequestContext> url_request_context_; | |
| 52 mutable std::unique_ptr<net::URLRequestJobFactory> url_request_job_factory_; | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(DeterministicHttpProtocolHandler); | |
| 55 }; | |
| 56 | |
| 57 } // namespace headless | |
| 58 | |
| 59 #endif // HEADLESS_PUBLIC_UTIL_DETERMINISTIC_HTTP_PROTOCOL_HANDLER_H_ | |
| OLD | NEW |