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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « headless/test/test_url_request_job.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: headless/test/test_url_request_job.cc
diff --git a/headless/test/test_url_request_job.cc b/headless/test/test_url_request_job.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bdde8962f0dcc3439a8ccfe5a7d83c9759209ca7
--- /dev/null
+++ b/headless/test/test_url_request_job.cc
@@ -0,0 +1,41 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "headless/test/test_url_request_job.h"
+
+#include "net/base/io_buffer.h"
+#include "net/http/http_response_headers.h"
+
+namespace headless {
+
+TestURLRequestJob::TestURLRequestJob(net::URLRequest* request,
+ net::NetworkDelegate* network_delegate,
+ const std::string& body)
+ : net::URLRequestJob(request, network_delegate),
+ body_(new net::StringIOBuffer(body)),
+ src_buf_(new net::DrainableIOBuffer(body_.get(), body_->size())) {}
+
+TestURLRequestJob::~TestURLRequestJob() {}
+
+void TestURLRequestJob::Start() {
+ NotifyHeadersComplete();
+}
+
+void TestURLRequestJob::GetResponseInfo(net::HttpResponseInfo* info) {
+ info->headers =
+ new net::HttpResponseHeaders("Content-Type: text/html\r\n\r\n");
+}
+
+int TestURLRequestJob::ReadRawData(net::IOBuffer* buf, int buf_size) {
+ scoped_refptr<net::DrainableIOBuffer> dest_buf(
+ new net::DrainableIOBuffer(buf, buf_size));
+ while (src_buf_->BytesRemaining() > 0 && dest_buf->BytesRemaining() > 0) {
+ *dest_buf->data() = *src_buf_->data();
+ src_buf_->DidConsume(1);
+ dest_buf->DidConsume(1);
+ }
+ return dest_buf->BytesConsumed();
+}
+
+} // namespace headless
« 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