Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 DCHECK_EQ(flags, kNone); | 54 DCHECK_EQ(flags, kNone); |
| 55 DCHECK_LE(size, std::numeric_limits<uint32_t>::max()); | 55 DCHECK_LE(size, std::numeric_limits<uint32_t>::max()); |
| 56 | 56 |
| 57 *read_size = 0; | 57 *read_size = 0; |
| 58 | 58 |
| 59 if (!size) { | 59 if (!size) { |
| 60 // Even if there is unread data available, mojo::ReadDataRaw() returns | 60 // Even if there is unread data available, mojo::ReadDataRaw() returns |
| 61 // FAILED_PRECONDITION when |size| is 0 and the producer handle was closed. | 61 // FAILED_PRECONDITION when |size| is 0 and the producer handle was closed. |
| 62 // But in this case, WebDataConsumerHandle::Reader::read() must return Ok. | 62 // But in this case, WebDataConsumerHandle::Reader::read() must return Ok. |
| 63 // So we use mojo::Wait() with 0 deadline to check whether readable or not. | 63 // So we use mojo::Wait() with 0 deadline to check whether readable or not. |
| 64 return HandleReadResult(mojo::Wait( | 64 MojoResult wait_result = mojo::Wait( |
| 65 context_->handle().get(), MOJO_HANDLE_SIGNAL_READABLE, 0, nullptr)); | 65 context_->handle().get(), MOJO_HANDLE_SIGNAL_READABLE, 0, nullptr); |
| 66 switch (wait_result) { | |
| 67 case MOJO_RESULT_OK: | |
| 68 return Ok; | |
| 69 case MOJO_RESULT_FAILED_PRECONDITION: | |
| 70 return Done; | |
| 71 case MOJO_RESULT_DEADLINE_EXCEEDED: | |
| 72 return ShouldWait; | |
| 73 default: | |
| 74 return UnexpectedError; | |
|
yhirano
2017/01/18 08:34:21
NOTREACHED() according to https://cs.chromium.org/
horo
2017/01/18 09:37:08
Done.
| |
| 75 } | |
| 66 } | 76 } |
| 67 | 77 |
| 68 uint32_t size_to_pass = size; | 78 uint32_t size_to_pass = size; |
| 69 MojoReadDataFlags flags_to_pass = MOJO_READ_DATA_FLAG_NONE; | 79 MojoReadDataFlags flags_to_pass = MOJO_READ_DATA_FLAG_NONE; |
| 70 MojoResult rv = mojo::ReadDataRaw(context_->handle().get(), data, | 80 MojoResult rv = mojo::ReadDataRaw(context_->handle().get(), data, |
| 71 &size_to_pass, flags_to_pass); | 81 &size_to_pass, flags_to_pass); |
| 72 if (rv == MOJO_RESULT_OK) | 82 if (rv == MOJO_RESULT_OK) |
| 73 *read_size = size_to_pass; | 83 *read_size = size_to_pass; |
| 74 | 84 |
| 75 return HandleReadResult(rv); | 85 return HandleReadResult(rv); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 std::unique_ptr<blink::WebDataConsumerHandle::Reader> | 148 std::unique_ptr<blink::WebDataConsumerHandle::Reader> |
| 139 WebDataConsumerHandleImpl::obtainReader(Client* client) { | 149 WebDataConsumerHandleImpl::obtainReader(Client* client) { |
| 140 return base::WrapUnique(new ReaderImpl(context_, client)); | 150 return base::WrapUnique(new ReaderImpl(context_, client)); |
| 141 } | 151 } |
| 142 | 152 |
| 143 const char* WebDataConsumerHandleImpl::debugName() const { | 153 const char* WebDataConsumerHandleImpl::debugName() const { |
| 144 return "WebDataConsumerHandleImpl"; | 154 return "WebDataConsumerHandleImpl"; |
| 145 } | 155 } |
| 146 | 156 |
| 147 } // namespace content | 157 } // namespace content |
| OLD | NEW |