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

Side by Side Diff: headless/test/test_url_request_job.cc

Issue 2092773002: headless: Allow per-context protocol handlers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed comments Created 4 years, 6 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
« no previous file with comments | « headless/test/test_url_request_job.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/test/test_url_request_job.h"
6
7 #include "net/base/io_buffer.h"
8 #include "net/http/http_response_headers.h"
9
10 namespace headless {
11
12 TestURLRequestJob::TestURLRequestJob(net::URLRequest* request,
13 net::NetworkDelegate* network_delegate,
14 const std::string& body)
15 : net::URLRequestJob(request, network_delegate),
16 body_(new net::StringIOBuffer(body)),
17 src_buf_(new net::DrainableIOBuffer(body_.get(), body_->size())) {}
18
19 TestURLRequestJob::~TestURLRequestJob() {}
20
21 void TestURLRequestJob::Start() {
22 NotifyHeadersComplete();
23 }
24
25 void TestURLRequestJob::GetResponseInfo(net::HttpResponseInfo* info) {
26 info->headers =
27 new net::HttpResponseHeaders("Content-Type: text/html\r\n\r\n");
28 }
29
30 int TestURLRequestJob::ReadRawData(net::IOBuffer* buf, int buf_size) {
31 scoped_refptr<net::DrainableIOBuffer> dest_buf(
32 new net::DrainableIOBuffer(buf, buf_size));
33 while (src_buf_->BytesRemaining() > 0 && dest_buf->BytesRemaining() > 0) {
34 *dest_buf->data() = *src_buf_->data();
35 src_buf_->DidConsume(1);
36 dest_buf->DidConsume(1);
37 }
38 return dest_buf->BytesConsumed();
39 }
40
41 } // namespace headless
OLDNEW
« no previous file with comments | « headless/test/test_url_request_job.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698