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

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

Issue 2363963002: Make WebDataConsumerHandleImpl return OK while zero-length reading of closed pipe. (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/child/web_data_consumer_handle_impl.h" 5 #include "content/child/web_data_consumer_handle_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <utility> 10 #include <utility>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 *read_size = 0; 57 *read_size = 0;
58 58
59 uint32_t size_to_pass = size; 59 uint32_t size_to_pass = size;
60 MojoReadDataFlags flags_to_pass = MOJO_READ_DATA_FLAG_NONE; 60 MojoReadDataFlags flags_to_pass = MOJO_READ_DATA_FLAG_NONE;
61 MojoResult rv = mojo::ReadDataRaw(context_->handle().get(), data, 61 MojoResult rv = mojo::ReadDataRaw(context_->handle().get(), data,
62 &size_to_pass, flags_to_pass); 62 &size_to_pass, flags_to_pass);
63 if (rv == MOJO_RESULT_OK) 63 if (rv == MOJO_RESULT_OK)
64 *read_size = size_to_pass; 64 *read_size = size_to_pass;
65 65
66 // Even if there is unread data available, mojo::ReadDataRaw() returns
67 // FAILED_PRECONDITION when |size| is 0 and the producer handle was closed.
68 // But in this case, WebDataConsumerHandle::Reader::read() must return Ok.
69 if (!size && rv == MOJO_RESULT_FAILED_PRECONDITION)
70 return Ok;
71
66 return HandleReadResult(rv); 72 return HandleReadResult(rv);
67 } 73 }
68 74
69 Result WebDataConsumerHandleImpl::ReaderImpl::beginRead(const void** buffer, 75 Result WebDataConsumerHandleImpl::ReaderImpl::beginRead(const void** buffer,
70 Flags flags, 76 Flags flags,
71 size_t* available) { 77 size_t* available) {
72 // We need this variable definition to avoid a link error. 78 // We need this variable definition to avoid a link error.
73 const Flags kNone = FlagNone; 79 const Flags kNone = FlagNone;
74 DCHECK_EQ(flags, kNone); 80 DCHECK_EQ(flags, kNone);
75 81
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 std::unique_ptr<blink::WebDataConsumerHandle::Reader> 135 std::unique_ptr<blink::WebDataConsumerHandle::Reader>
130 WebDataConsumerHandleImpl::obtainReader(Client* client) { 136 WebDataConsumerHandleImpl::obtainReader(Client* client) {
131 return base::WrapUnique(new ReaderImpl(context_, client)); 137 return base::WrapUnique(new ReaderImpl(context_, client));
132 } 138 }
133 139
134 const char* WebDataConsumerHandleImpl::debugName() const { 140 const char* WebDataConsumerHandleImpl::debugName() const {
135 return "WebDataConsumerHandleImpl"; 141 return "WebDataConsumerHandleImpl";
136 } 142 }
137 143
138 } // namespace content 144 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698