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 "device/serial/data_sink_receiver.h" | 5 #include "device/serial/data_sink_receiver.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "device/serial/async_waiter.h" | 10 #include "device/serial/async_waiter.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 class DataSinkReceiver::Buffer : public ReadOnlyBuffer { | 42 class DataSinkReceiver::Buffer : public ReadOnlyBuffer { |
43 public: | 43 public: |
44 Buffer(scoped_refptr<DataSinkReceiver> receiver, | 44 Buffer(scoped_refptr<DataSinkReceiver> receiver, |
45 const char* buffer, | 45 const char* buffer, |
46 uint32_t buffer_size); | 46 uint32_t buffer_size); |
47 virtual ~Buffer(); | 47 virtual ~Buffer(); |
48 | 48 |
49 void Cancel(int32_t error); | 49 void Cancel(int32_t error); |
50 | 50 |
51 // ReadOnlyBuffer overrides. | 51 // ReadOnlyBuffer overrides. |
52 virtual const char* GetData() OVERRIDE; | 52 virtual const char* GetData() override; |
53 virtual uint32_t GetSize() OVERRIDE; | 53 virtual uint32_t GetSize() override; |
54 virtual void Done(uint32_t bytes_read) OVERRIDE; | 54 virtual void Done(uint32_t bytes_read) override; |
55 virtual void DoneWithError(uint32_t bytes_read, int32_t error) OVERRIDE; | 55 virtual void DoneWithError(uint32_t bytes_read, int32_t error) override; |
56 | 56 |
57 private: | 57 private: |
58 // The DataSinkReceiver whose data pipe we are providing a view. | 58 // The DataSinkReceiver whose data pipe we are providing a view. |
59 scoped_refptr<DataSinkReceiver> receiver_; | 59 scoped_refptr<DataSinkReceiver> receiver_; |
60 | 60 |
61 const char* buffer_; | 61 const char* buffer_; |
62 uint32_t buffer_size_; | 62 uint32_t buffer_size_; |
63 | 63 |
64 // Whether this receive has been cancelled. | 64 // Whether this receive has been cancelled. |
65 bool cancelled_; | 65 bool cancelled_; |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 MojoResult result = | 297 MojoResult result = |
298 mojo::ReadDataRaw(handle, NULL, &num_bytes, MOJO_READ_DATA_FLAG_DISCARD); | 298 mojo::ReadDataRaw(handle, NULL, &num_bytes, MOJO_READ_DATA_FLAG_DISCARD); |
299 if (result != MOJO_RESULT_OK) | 299 if (result != MOJO_RESULT_OK) |
300 return result; | 300 return result; |
301 DCHECK(num_bytes <= bytes_to_flush_); | 301 DCHECK(num_bytes <= bytes_to_flush_); |
302 bytes_to_flush_ -= num_bytes; | 302 bytes_to_flush_ -= num_bytes; |
303 return bytes_to_flush_ == 0 ? MOJO_RESULT_OK : MOJO_RESULT_SHOULD_WAIT; | 303 return bytes_to_flush_ == 0 ? MOJO_RESULT_OK : MOJO_RESULT_SHOULD_WAIT; |
304 } | 304 } |
305 | 305 |
306 } // namespace device | 306 } // namespace device |
OLD | NEW |