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

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

Issue 2750273002: Revert of Mojo EDK: Introduce MojoQueryHandleSignalsState API (Closed)
Patch Set: Created 3 years, 9 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 | « no previous file | mojo/android/javatests/src/org/chromium/mojo/HandleMock.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 const Flags kNone = FlagNone; 55 const Flags kNone = FlagNone;
56 DCHECK_EQ(flags, kNone); 56 DCHECK_EQ(flags, kNone);
57 DCHECK_LE(size, std::numeric_limits<uint32_t>::max()); 57 DCHECK_LE(size, std::numeric_limits<uint32_t>::max());
58 58
59 *read_size = 0; 59 *read_size = 0;
60 60
61 if (!size) { 61 if (!size) {
62 // Even if there is unread data available, mojo::ReadDataRaw() returns 62 // Even if there is unread data available, mojo::ReadDataRaw() returns
63 // FAILED_PRECONDITION when |size| is 0 and the producer handle was closed. 63 // FAILED_PRECONDITION when |size| is 0 and the producer handle was closed.
64 // But in this case, WebDataConsumerHandle::Reader::read() must return Ok. 64 // But in this case, WebDataConsumerHandle::Reader::read() must return Ok.
65 // So we query the signals state directly. 65 // So we use mojo::Wait() with 0 deadline to check whether readable or not.
66 mojo::HandleSignalsState state = context_->handle()->QuerySignalsState(); 66 MojoResult wait_result = mojo::Wait(
67 if (state.readable()) 67 context_->handle().get(), MOJO_HANDLE_SIGNAL_READABLE, 0, nullptr);
68 return Ok; 68 switch (wait_result) {
69 if (state.never_readable()) 69 case MOJO_RESULT_OK:
70 return Done; 70 return Ok;
71 return ShouldWait; 71 case MOJO_RESULT_FAILED_PRECONDITION:
72 return Done;
73 case MOJO_RESULT_DEADLINE_EXCEEDED:
74 return ShouldWait;
75 default:
76 NOTREACHED();
77 return UnexpectedError;
78 }
72 } 79 }
73 80
74 uint32_t size_to_pass = size; 81 uint32_t size_to_pass = size;
75 MojoReadDataFlags flags_to_pass = MOJO_READ_DATA_FLAG_NONE; 82 MojoReadDataFlags flags_to_pass = MOJO_READ_DATA_FLAG_NONE;
76 MojoResult rv = mojo::ReadDataRaw(context_->handle().get(), data, 83 MojoResult rv = mojo::ReadDataRaw(context_->handle().get(), data,
77 &size_to_pass, flags_to_pass); 84 &size_to_pass, flags_to_pass);
78 if (rv == MOJO_RESULT_OK) 85 if (rv == MOJO_RESULT_OK)
79 *read_size = size_to_pass; 86 *read_size = size_to_pass;
80 87
81 return HandleReadResult(rv); 88 return HandleReadResult(rv);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 std::unique_ptr<blink::WebDataConsumerHandle::Reader> 151 std::unique_ptr<blink::WebDataConsumerHandle::Reader>
145 WebDataConsumerHandleImpl::obtainReader(Client* client) { 152 WebDataConsumerHandleImpl::obtainReader(Client* client) {
146 return base::WrapUnique(new ReaderImpl(context_, client)); 153 return base::WrapUnique(new ReaderImpl(context_, client));
147 } 154 }
148 155
149 const char* WebDataConsumerHandleImpl::debugName() const { 156 const char* WebDataConsumerHandleImpl::debugName() const {
150 return "WebDataConsumerHandleImpl"; 157 return "WebDataConsumerHandleImpl";
151 } 158 }
152 159
153 } // namespace content 160 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | mojo/android/javatests/src/org/chromium/mojo/HandleMock.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698