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

Unified Diff: content/network/net_adapters.cc

Issue 2817453002: Bring back the URLLoader from the old Mandoline network service. (Closed)
Patch Set: fix checkdeps Created 3 years, 8 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 | « content/network/net_adapters.h ('k') | content/network/network_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/network/net_adapters.cc
diff --git a/content/network/net_adapters.cc b/content/network/net_adapters.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1481b53b13af11f6514bf9e9d12aa2a42dd93626
--- /dev/null
+++ b/content/network/net_adapters.cc
@@ -0,0 +1,54 @@
+// Copyright 2017 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 "content/network/net_adapters.h"
+
+#include "net/base/net_errors.h"
+
+namespace content {
+
+namespace {
+const uint32_t kMaxBufSize = 64 * 1024;
+}
+
+NetToMojoPendingBuffer::NetToMojoPendingBuffer(
+ mojo::ScopedDataPipeProducerHandle handle,
+ void* buffer)
+ : handle_(std::move(handle)), buffer_(buffer) {}
+
+NetToMojoPendingBuffer::~NetToMojoPendingBuffer() {
+ if (handle_.is_valid())
+ EndWriteDataRaw(handle_.get(), 0);
+}
+
+MojoResult NetToMojoPendingBuffer::BeginWrite(
+ mojo::ScopedDataPipeProducerHandle* handle,
+ scoped_refptr<NetToMojoPendingBuffer>* pending,
+ uint32_t* num_bytes) {
+ void* buf;
+ *num_bytes = 0;
+ MojoResult result = BeginWriteDataRaw(handle->get(), &buf, num_bytes,
+ MOJO_WRITE_DATA_FLAG_NONE);
+ if (result == MOJO_RESULT_OK) {
+ if (*num_bytes > kMaxBufSize)
+ *num_bytes = kMaxBufSize;
+ *pending = new NetToMojoPendingBuffer(std::move(*handle), buf);
+ }
+ return result;
+}
+
+mojo::ScopedDataPipeProducerHandle NetToMojoPendingBuffer::Complete(
+ uint32_t num_bytes) {
+ EndWriteDataRaw(handle_.get(), num_bytes);
+ buffer_ = NULL;
+ return std::move(handle_);
+}
+
+NetToMojoIOBuffer::NetToMojoIOBuffer(NetToMojoPendingBuffer* pending_buffer)
+ : net::WrappedIOBuffer(pending_buffer->buffer()),
+ pending_buffer_(pending_buffer) {}
+
+NetToMojoIOBuffer::~NetToMojoIOBuffer() {}
+
+} // namespace content
« no previous file with comments | « content/network/net_adapters.h ('k') | content/network/network_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698