| 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 #ifndef CHROMEOS_DBUS_PIPE_READER_H_ | 5 #ifndef CHROMEOS_DBUS_PIPE_READER_H_ |
| 6 #define CHROMEOS_DBUS_PIPE_READER_H_ | 6 #define CHROMEOS_DBUS_PIPE_READER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/files/file.h" | 12 #include "base/files/scoped_file.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "chromeos/chromeos_export.h" | 16 #include "chromeos/chromeos_export.h" |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 class TaskRunner; | 19 class TaskRunner; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace net { | 22 namespace net { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 PipeReader(const scoped_refptr<base::TaskRunner>& task_runner, | 41 PipeReader(const scoped_refptr<base::TaskRunner>& task_runner, |
| 42 const IOCompleteCallback& callback); | 42 const IOCompleteCallback& callback); |
| 43 virtual ~PipeReader(); | 43 virtual ~PipeReader(); |
| 44 | 44 |
| 45 // Starts data collection. | 45 // Starts data collection. |
| 46 // Returns the write end of the pipe if stream was setup correctly. | 46 // Returns the write end of the pipe if stream was setup correctly. |
| 47 // On success data will automatically be accumulated into a string that | 47 // On success data will automatically be accumulated into a string that |
| 48 // can be retrieved with PipeReader::data(). To shutdown collection delete | 48 // can be retrieved with PipeReader::data(). To shutdown collection delete |
| 49 // the instance and/or use PipeReader::OnDataReady(-1). | 49 // the instance and/or use PipeReader::OnDataReady(-1). |
| 50 base::File StartIO(); | 50 base::ScopedFD StartIO(); |
| 51 | 51 |
| 52 // Called when pipe data are available. Can also be used to shutdown | 52 // Called when pipe data are available. Can also be used to shutdown |
| 53 // data collection by passing -1 for |byte_count|. | 53 // data collection by passing -1 for |byte_count|. |
| 54 void OnDataReady(int byte_count); | 54 void OnDataReady(int byte_count); |
| 55 | 55 |
| 56 // Virtual function that subclasses will override in order to deal | 56 // Virtual function that subclasses will override in order to deal |
| 57 // with incoming data. | 57 // with incoming data. |
| 58 virtual void AcceptData(const char *data, int length) = 0; | 58 virtual void AcceptData(const char *data, int length) = 0; |
| 59 | 59 |
| 60 private: | 60 private: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 83 | 83 |
| 84 private: | 84 private: |
| 85 std::string data_; | 85 std::string data_; |
| 86 | 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(PipeReaderForString); | 87 DISALLOW_COPY_AND_ASSIGN(PipeReaderForString); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 } // namespace chromeos | 90 } // namespace chromeos |
| 91 | 91 |
| 92 #endif // CHROMEOS_DBUS_PIPE_READER_H_ | 92 #endif // CHROMEOS_DBUS_PIPE_READER_H_ |
| OLD | NEW |