Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: headless/public/util/deterministic_http_protocol_handler.h

Issue 2863953003: Headless: Remove obsolete Mojo code and some other obsolete APIs (Closed)
Patch Set: Rebased Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "headless/public/headless_export.h"
12 #include "net/url_request/url_request_job_factory.h" 12 #include "net/url_request/url_request_job_factory.h"
13 13
14 namespace net { 14 namespace net {
15 class URLRequestContext; 15 class URLRequestContext;
16 class URLRequestJobFactory; 16 class URLRequestJobFactory;
17 } // namespace 17 } // namespace
18 18
19 namespace headless { 19 namespace headless {
20 class DeterministicDispatcher; 20 class DeterministicDispatcher;
21 class HeadlessBrowserContext;
21 22
22 // A deterministic protocol handler. Requests made to this protocol handler 23 // A deterministic protocol handler. Requests made to this protocol handler
23 // will return in order of creation, regardless of what order the network 24 // 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 // returns them in. This helps remove one large source of network related
25 // non determinism at the cost of slower page loads. 26 // non determinism at the cost of slower page loads.
26 class HEADLESS_EXPORT DeterministicHttpProtocolHandler 27 class HEADLESS_EXPORT DeterministicHttpProtocolHandler
27 : public net::URLRequestJobFactory::ProtocolHandler { 28 : public net::URLRequestJobFactory::ProtocolHandler {
28 public: 29 public:
29 // Note |deterministic_dispatcher| is expected to be shared across a number of 30 // Note |deterministic_dispatcher| is expected to be shared across a number of
30 // protocol handlers, e.g. for http & https protocols. 31 // protocol handlers, e.g. for http & https protocols.
31 DeterministicHttpProtocolHandler( 32 DeterministicHttpProtocolHandler(
32 DeterministicDispatcher* deterministic_dispatcher, 33 DeterministicDispatcher* deterministic_dispatcher,
33 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); 34 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner);
34 ~DeterministicHttpProtocolHandler() override; 35 ~DeterministicHttpProtocolHandler() override;
35 36
36 net::URLRequestJob* MaybeCreateJob( 37 net::URLRequestJob* MaybeCreateJob(
37 net::URLRequest* request, 38 net::URLRequest* request,
38 net::NetworkDelegate* network_delegate) const override; 39 net::NetworkDelegate* network_delegate) const override;
39 40
41 void SetHeadlessBrowserContext(
42 HeadlessBrowserContext* headless_browser_context) {
43 headless_browser_context_ = headless_browser_context;
44 }
45
40 private: 46 private:
41 class NopGenericURLRequestJobDelegate; 47 class NopGenericURLRequestJobDelegate;
42 48
43 DeterministicDispatcher* deterministic_dispatcher_; // NOT OWNED. 49 DeterministicDispatcher* deterministic_dispatcher_; // NOT OWNED.
50 HeadlessBrowserContext* headless_browser_context_; // NOT OWNED.
44 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 51 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
45 std::unique_ptr<NopGenericURLRequestJobDelegate> nop_delegate_; 52 std::unique_ptr<NopGenericURLRequestJobDelegate> nop_delegate_;
46 53
47 // |url_request_context_| and |url_request_job_factory_| are lazily created on 54 // |url_request_context_| and |url_request_job_factory_| are lazily created on
48 // the IO thread. The URLRequestContext is setup to bypass any user-specified 55 // the IO thread. The URLRequestContext is setup to bypass any user-specified
49 // protocol handlers including this one. This is necessary to actually fetch 56 // protocol handlers including this one. This is necessary to actually fetch
50 // http resources. 57 // http resources.
51 mutable std::unique_ptr<net::URLRequestContext> url_request_context_; 58 mutable std::unique_ptr<net::URLRequestContext> url_request_context_;
52 mutable std::unique_ptr<net::URLRequestJobFactory> url_request_job_factory_; 59 mutable std::unique_ptr<net::URLRequestJobFactory> url_request_job_factory_;
53 60
54 DISALLOW_COPY_AND_ASSIGN(DeterministicHttpProtocolHandler); 61 DISALLOW_COPY_AND_ASSIGN(DeterministicHttpProtocolHandler);
55 }; 62 };
56 63
57 } // namespace headless 64 } // namespace headless
58 65
59 #endif // HEADLESS_PUBLIC_UTIL_DETERMINISTIC_HTTP_PROTOCOL_HANDLER_H_ 66 #endif // HEADLESS_PUBLIC_UTIL_DETERMINISTIC_HTTP_PROTOCOL_HANDLER_H_
OLDNEW
« no previous file with comments | « headless/public/headless_web_contents.h ('k') | headless/public/util/deterministic_http_protocol_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698