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

Side by Side Diff: content/child/mojo_pipe_received_data.cc

Issue 1693563002: PROTOTYPE: PlzNavigate: use a Mojo data pipe to stream navigation data to the renderer. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Browser sends URLRequest id to the renderer and renderer uses intermediary buffer for data: none he… Created 4 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 unified diff | Download patch
« no previous file with comments | « content/child/mojo_pipe_received_data.h ('k') | content/child/request_info.h » ('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 2015 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/child/mojo_pipe_received_data.h"
6
7 #include "base/logging.h"
8
9 namespace content {
10
11 // static
12 scoped_ptr<RequestPeer::ReceivedData> MojoPipeReceivedData::Create(
13 mojo::DataPipeConsumerHandle source,
14 const void* buffer,
15 uint32_t num_bytes) {
16 return make_scoped_ptr(new MojoPipeReceivedData(source, buffer, num_bytes));
17 }
18
19 MojoPipeReceivedData::MojoPipeReceivedData(mojo::DataPipeConsumerHandle source,
20 const void* buffer,
21 uint32_t num_bytes)
22 : num_bytes_(num_bytes) {
23 real_contents_ = make_scoped_ptr(new char[num_bytes_]);
24 memcpy(real_contents_.get(), buffer, num_bytes_);
25 CHECK_EQ(EndReadDataRaw(source, num_bytes_), MOJO_RESULT_OK);
26 }
27
28 MojoPipeReceivedData::~MojoPipeReceivedData() {
29 // TODO(carlosk): in the final implementation EndReadDataRaw should be called
30 // here.
31 // TODO(carlosk): most probably needs stronger checks to decide if
32 // EndReadDataRaw should be called at all. Is the pointer still valid? Is the
33 // pipe still open? Etc...
34 // CHECK_EQ(EndReadDataRaw(UNSAFEPTR_source_, num_bytes_), MOJO_RESULT_OK);
35 }
36
37 const char* MojoPipeReceivedData::payload() const {
38 return real_contents_.get();
39 }
40
41 int MojoPipeReceivedData::length() const {
42 // TODO(carlosk): Must take care of integer range conversion from uint32_t to
43 // int.
44 return num_bytes_;
45 }
46
47 int MojoPipeReceivedData::encoded_length() const {
48 // TODO(carlosk): we have to figure out how to send the encoded_length
49 // information from the browser to here as it used to be send along with the
50 // shared memory buffer flow control messages. For now just returning the same
51 // value as length.
52 return num_bytes_;
53 }
54
55 } // namespace content
OLDNEW
« no previous file with comments | « content/child/mojo_pipe_received_data.h ('k') | content/child/request_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698