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

Side by Side Diff: content/network/net_adapters.cc

Issue 2906543002: Add support for reading blobs when using the network service. (Closed)
Patch Set: fix threading issue with weakptr Created 3 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 | « content/network/net_adapters.h ('k') | content/network/url_loader_impl.cc » ('j') | 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 2017 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 "content/network/net_adapters.h"
6
7 #include "net/base/net_errors.h"
8
9 namespace content {
10
11 namespace {
12 const uint32_t kMaxBufSize = 64 * 1024;
13 }
14
15 NetToMojoPendingBuffer::NetToMojoPendingBuffer(
16 mojo::ScopedDataPipeProducerHandle handle,
17 void* buffer)
18 : handle_(std::move(handle)), buffer_(buffer) {}
19
20 NetToMojoPendingBuffer::~NetToMojoPendingBuffer() {
21 if (handle_.is_valid())
22 EndWriteDataRaw(handle_.get(), 0);
23 }
24
25 MojoResult NetToMojoPendingBuffer::BeginWrite(
26 mojo::ScopedDataPipeProducerHandle* handle,
27 scoped_refptr<NetToMojoPendingBuffer>* pending,
28 uint32_t* num_bytes) {
29 void* buf;
30 *num_bytes = 0;
31 MojoResult result = BeginWriteDataRaw(handle->get(), &buf, num_bytes,
32 MOJO_WRITE_DATA_FLAG_NONE);
33 if (result == MOJO_RESULT_OK) {
34 if (*num_bytes > kMaxBufSize)
35 *num_bytes = kMaxBufSize;
36 *pending = new NetToMojoPendingBuffer(std::move(*handle), buf);
37 }
38 return result;
39 }
40
41 mojo::ScopedDataPipeProducerHandle NetToMojoPendingBuffer::Complete(
42 uint32_t num_bytes) {
43 EndWriteDataRaw(handle_.get(), num_bytes);
44 buffer_ = NULL;
45 return std::move(handle_);
46 }
47
48 NetToMojoIOBuffer::NetToMojoIOBuffer(NetToMojoPendingBuffer* pending_buffer)
49 : net::WrappedIOBuffer(pending_buffer->buffer()),
50 pending_buffer_(pending_buffer) {}
51
52 NetToMojoIOBuffer::~NetToMojoIOBuffer() {}
53
54 } // namespace content
OLDNEW
« no previous file with comments | « content/network/net_adapters.h ('k') | content/network/url_loader_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698