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

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

Issue 2352663003: Adds a --deterministic-fetch flag to headless_shell (Closed)
Patch Set: Added a few comments Created 4 years, 3 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
(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 #include "headless/public/util/deterministic_http_protocol_handler.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "headless/public/headless_browser_context.h"
9 #include "headless/public/util/deterministic_dispatcher.h"
10 #include "headless/public/util/generic_url_request_job.h"
11 #include "headless/public/util/http_url_fetcher.h"
12 #include "net/url_request/url_request_context.h"
13
14 namespace headless {
15
16 class DeterministicHttpProtocolHandler::NopGenericURLRequestJobDelegate
17 : public GenericURLRequestJob::Delegate {
18 public:
19 NopGenericURLRequestJobDelegate() {}
20 ~NopGenericURLRequestJobDelegate() override {}
21
22 // GenericURLRequestJob::Delegate methods:
23 bool BlockOrRewriteRequest(
24 const GURL& url,
25 const std::string& referrer,
26 GenericURLRequestJob::RewriteCallback callback) override {
27 return false;
28 }
29
30 const GenericURLRequestJob::HttpResponse* MaybeMatchResource(
31 const GURL& url,
32 const net::HttpRequestHeaders& request_headers) override {
33 return nullptr;
34 }
35
36 void OnResourceLoadComplete(const GURL& final_url,
37 const std::string& mime_type,
38 int http_response_code) override {}
39 };
Sami 2016/09/22 12:09:40 DISALLOW_COPY_AND_ASSIGN
alex clarke (OOO till 29th) 2016/09/23 13:29:21 Done.
40
41 DeterministicHttpProtocolHandler::DeterministicHttpProtocolHandler(
42 DeterministicDispatcher* deterministic_dispatcher)
43 : deterministic_dispatcher_(deterministic_dispatcher),
44 browser_context_(nullptr),
45 nop_delagate_(new NopGenericURLRequestJobDelegate()) {}
46
47 DeterministicHttpProtocolHandler::~DeterministicHttpProtocolHandler() {}
48
49 net::URLRequestJob* DeterministicHttpProtocolHandler::MaybeCreateJob(
50 net::URLRequest* request,
51 net::NetworkDelegate* network_delegate) const {
52 std::unique_ptr<net::URLRequestContext> url_request_context(
Sami 2016/09/22 12:09:40 This is a pretty big object. Could we construct it
alex clarke (OOO till 29th) 2016/09/23 13:29:21 It's shared at the ProtocolHandler level now.
53 new net::URLRequestContext());
54
55 url_request_context->set_http_transaction_factory(
Sami 2016/09/22 12:09:40 Should we use CopyFrom instead? Otherwise the cont
alex clarke (OOO till 29th) 2016/09/23 13:29:21 Done.
56 browser_context_->GetRequestContext()->http_transaction_factory());
57
58 url_request_context->set_cookie_store(
59 browser_context_->GetRequestContext()->cookie_store());
60
61 return new GenericURLRequestJob(
62 request, network_delegate, deterministic_dispatcher_,
63 base::MakeUnique<HttpUrlFetcher>(std::move(url_request_context)),
64 nop_delagate_.get());
65 }
66
67 } // namespace headless
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698