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 "mojo/common/data_pipe_drainer.h" | 5 #include "mojo/common/data_pipe_drainer.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 | 10 |
9 namespace mojo { | 11 namespace mojo { |
10 namespace common { | 12 namespace common { |
11 | 13 |
12 DataPipeDrainer::DataPipeDrainer(Client* client, | 14 DataPipeDrainer::DataPipeDrainer(Client* client, |
13 mojo::ScopedDataPipeConsumerHandle source) | 15 mojo::ScopedDataPipeConsumerHandle source) |
14 : client_(client), source_(source.Pass()), weak_factory_(this) { | 16 : client_(client), source_(std::move(source)), weak_factory_(this) { |
15 DCHECK(client_); | 17 DCHECK(client_); |
16 ReadData(); | 18 ReadData(); |
17 } | 19 } |
18 | 20 |
19 DataPipeDrainer::~DataPipeDrainer() {} | 21 DataPipeDrainer::~DataPipeDrainer() {} |
20 | 22 |
21 void DataPipeDrainer::ReadData() { | 23 void DataPipeDrainer::ReadData() { |
22 const void* buffer = nullptr; | 24 const void* buffer = nullptr; |
23 uint32_t num_bytes = 0; | 25 uint32_t num_bytes = 0; |
24 MojoResult rv = BeginReadDataRaw(source_.get(), &buffer, &num_bytes, | 26 MojoResult rv = BeginReadDataRaw(source_.get(), &buffer, &num_bytes, |
(...skipping 16 matching lines...) Expand all Loading... |
41 source_.get(), MOJO_HANDLE_SIGNAL_READABLE, MOJO_DEADLINE_INDEFINITE, | 43 source_.get(), MOJO_HANDLE_SIGNAL_READABLE, MOJO_DEADLINE_INDEFINITE, |
42 base::Bind(&DataPipeDrainer::WaitComplete, weak_factory_.GetWeakPtr())); | 44 base::Bind(&DataPipeDrainer::WaitComplete, weak_factory_.GetWeakPtr())); |
43 } | 45 } |
44 | 46 |
45 void DataPipeDrainer::WaitComplete(MojoResult result) { | 47 void DataPipeDrainer::WaitComplete(MojoResult result) { |
46 ReadData(); | 48 ReadData(); |
47 } | 49 } |
48 | 50 |
49 } // namespace common | 51 } // namespace common |
50 } // namespace mojo | 52 } // namespace mojo |
OLD | NEW |