| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 | 12 |
| 13 namespace mojo { | 13 namespace mojo { |
| 14 namespace common { | 14 namespace common { |
| 15 | 15 |
| 16 DataPipeDrainer::DataPipeDrainer(Client* client, | 16 DataPipeDrainer::DataPipeDrainer(Client* client, |
| 17 mojo::ScopedDataPipeConsumerHandle source) | 17 mojo::ScopedDataPipeConsumerHandle source) |
| 18 : client_(client), | 18 : client_(client), |
| 19 source_(std::move(source)), | 19 source_(std::move(source)), |
| 20 handle_watcher_(FROM_HERE), | 20 handle_watcher_(FROM_HERE, Watcher::ArmingPolicy::AUTOMATIC), |
| 21 weak_factory_(this) { | 21 weak_factory_(this) { |
| 22 DCHECK(client_); | 22 DCHECK(client_); |
| 23 handle_watcher_.Start( | 23 handle_watcher_.Start( |
| 24 source_.get(), MOJO_HANDLE_SIGNAL_READABLE, | 24 source_.get(), MOJO_HANDLE_SIGNAL_READABLE, |
| 25 base::Bind(&DataPipeDrainer::WaitComplete, weak_factory_.GetWeakPtr())); | 25 base::Bind(&DataPipeDrainer::WaitComplete, weak_factory_.GetWeakPtr())); |
| 26 } | 26 } |
| 27 | 27 |
| 28 DataPipeDrainer::~DataPipeDrainer() {} | 28 DataPipeDrainer::~DataPipeDrainer() {} |
| 29 | 29 |
| 30 void DataPipeDrainer::ReadData() { | 30 void DataPipeDrainer::ReadData() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 41 DCHECK(false) << "Unhandled MojoResult: " << rv; | 41 DCHECK(false) << "Unhandled MojoResult: " << rv; |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 | 44 |
| 45 void DataPipeDrainer::WaitComplete(MojoResult result) { | 45 void DataPipeDrainer::WaitComplete(MojoResult result) { |
| 46 ReadData(); | 46 ReadData(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 } // namespace common | 49 } // namespace common |
| 50 } // namespace mojo | 50 } // namespace mojo |
| OLD | NEW |