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 "net/url_request/url_request_job_factory.h" | |
| 11 | |
| 12 namespace net { | |
| 13 class URLRequestContext; | |
| 14 } // namespace | |
| 15 | |
| 16 namespace headless { | |
| 17 class DeterministicDispatcher; | |
| 18 class HeadlessBrowserContext; | |
| 19 | |
| 20 // A deterministic protocol handler. Requests make to this protocol handler | |
| 21 // will return in order of creation, regardless of what order the network | |
| 22 // returns them in. This helps remove one large source of network related | |
| 23 // non determinism at the cost of slower page loads. | |
| 24 class DeterministicHttpProtocolHandler | |
| 25 : public net::URLRequestJobFactory::ProtocolHandler { | |
| 26 public: | |
| 27 // Note |deterministic_dispatcher| is expected to be shared across a number of | |
| 28 // protocol handlers, e.g. for http & https protocols. | |
| 29 explicit DeterministicHttpProtocolHandler( | |
| 30 DeterministicDispatcher* deterministic_dispatcher); | |
| 31 ~DeterministicHttpProtocolHandler() override; | |
| 32 | |
| 33 net::URLRequestJob* MaybeCreateJob( | |
| 34 net::URLRequest* request, | |
| 35 net::NetworkDelegate* network_delegate) const override; | |
| 36 | |
| 37 void set_browser_context(HeadlessBrowserContext* browser_context) { | |
|
Sami
2016/09/22 12:09:40
I wonder if we could avoid the dependency on the b
alex clarke (OOO till 29th)
2016/09/23 13:29:21
We can get the context from the request itself.
| |
| 38 browser_context_ = browser_context; | |
| 39 } | |
| 40 | |
| 41 private: | |
| 42 class NopGenericURLRequestJobDelegate; | |
| 43 | |
| 44 DeterministicDispatcher* deterministic_dispatcher_; // NOT OWNED. | |
| 45 HeadlessBrowserContext* browser_context_; // NOT OWNED. | |
| 46 std::unique_ptr<NopGenericURLRequestJobDelegate> nop_delagate_; | |
| 47 | |
| 48 DISALLOW_COPY_AND_ASSIGN(DeterministicHttpProtocolHandler); | |
| 49 }; | |
| 50 | |
| 51 } // namespace headless | |
| 52 | |
| 53 #endif // HEADLESS_PUBLIC_UTIL_DETERMINISTIC_HTTP_PROTOCOL_HANDLER_H_ | |
| OLD | NEW |