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 MOJO_SHELL_DATA_PIPE_UTILS_H_ | 5 #ifndef MOJO_SHELL_DATA_PIPE_UTILS_H_ |
6 #define MOJO_SHELL_DATA_PIPE_UTILS_H_ | 6 #define MOJO_SHELL_DATA_PIPE_UTILS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 base::TaskRunner* task_runner, | 28 base::TaskRunner* task_runner, |
29 const base::Callback<void(bool /*success*/)>& callback); | 29 const base::Callback<void(bool /*success*/)>& callback); |
30 | 30 |
31 // Copies the data from |source| into |contents| and returns true on success and | 31 // Copies the data from |source| into |contents| and returns true on success and |
32 // false on error. In case of I/O error, |contents| holds the data that could | 32 // false on error. In case of I/O error, |contents| holds the data that could |
33 // be read from source before the error occurred. | 33 // be read from source before the error occurred. |
34 bool MOJO_COMMON_EXPORT BlockingCopyToString( | 34 bool MOJO_COMMON_EXPORT BlockingCopyToString( |
35 ScopedDataPipeConsumerHandle source, | 35 ScopedDataPipeConsumerHandle source, |
36 std::string* contents); | 36 std::string* contents); |
37 | 37 |
| 38 // Return true and the first newline terminated line from source. Return false |
| 39 // if more than max_line_length bytes are scanned without seeing a newline, or |
| 40 // if the timeout is exceeded. |
| 41 bool MOJO_COMMON_EXPORT BlockingPeekLine( |
| 42 DataPipeConsumerHandle source, |
| 43 std::string* line, |
| 44 size_t max_line_length, |
| 45 MojoDeadline timeout); |
| 46 |
| 47 // Return true and the first bytes_length bytes from source. Return false |
| 48 // if the timeout is exceeded. |
| 49 bool MOJO_COMMON_EXPORT BlockingPeekNBytes( |
| 50 DataPipeConsumerHandle source, |
| 51 std::string* bytes, |
| 52 size_t bytes_length, |
| 53 MojoDeadline timeout); |
| 54 |
38 } // namespace common | 55 } // namespace common |
39 } // namespace mojo | 56 } // namespace mojo |
40 | 57 |
41 #endif // MOJO_SHELL_DATA_PIPE_UTILS_H_ | 58 #endif // MOJO_SHELL_DATA_PIPE_UTILS_H_ |
OLD | NEW |