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_DATA_PIPE_UTILS_DATA_PIPE_UTILS_H_ | 5 #ifndef MOJO_DATA_PIPE_UTILS_DATA_PIPE_UTILS_H_ |
6 #define MOJO_DATA_PIPE_UTILS_DATA_PIPE_UTILS_H_ | 6 #define MOJO_DATA_PIPE_UTILS_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" |
| 11 #include "base/files/scoped_file.h" |
11 #include "base/threading/platform_thread.h" | 12 #include "base/threading/platform_thread.h" |
12 #include "mojo/public/cpp/system/core.h" | 13 #include "mojo/public/cpp/system/core.h" |
13 | 14 |
14 namespace base { | 15 namespace base { |
15 class FilePath; | 16 class FilePath; |
16 class TaskRunner; | 17 class TaskRunner; |
17 } | 18 } |
18 | 19 |
19 namespace mojo { | 20 namespace mojo { |
20 namespace common { | 21 namespace common { |
(...skipping 14 matching lines...) Expand all Loading... |
35 | 36 |
36 // Copies the data from |source| into |contents| and returns true on success and | 37 // Copies the data from |source| into |contents| and returns true on success and |
37 // false on error. In case of I/O error, |contents| holds the data that could | 38 // false on error. In case of I/O error, |contents| holds the data that could |
38 // be read from source before the error occurred. | 39 // be read from source before the error occurred. |
39 bool BlockingCopyToString(ScopedDataPipeConsumerHandle source, | 40 bool BlockingCopyToString(ScopedDataPipeConsumerHandle source, |
40 std::string* contents); | 41 std::string* contents); |
41 | 42 |
42 bool BlockingCopyFromString(const std::string& source, | 43 bool BlockingCopyFromString(const std::string& source, |
43 const ScopedDataPipeProducerHandle& destination); | 44 const ScopedDataPipeProducerHandle& destination); |
44 | 45 |
45 // Synchronously copies data from source to the destination file returning true | 46 // Synchronously copies source data to a temporary file, returning a file |
46 // on success and false on error. In case of an error, |destination| holds the | 47 // pointer on success and NULL on error. The temporary file is unlinked |
47 // data that could be read from the source before the error occured. | 48 // immediately so that it is only accessible by file pointer (and removed once |
48 bool BlockingCopyToFile(ScopedDataPipeConsumerHandle source, | 49 // closed or the creating process dies). |
49 const base::FilePath& destination); | 50 base::ScopedFILE BlockingCopyToTempFile(ScopedDataPipeConsumerHandle source); |
50 | 51 |
51 } // namespace common | 52 } // namespace common |
52 } // namespace mojo | 53 } // namespace mojo |
53 | 54 |
54 #endif // MOJO_DATA_PIPE_UTILS_DATA_PIPE_UTILS_H_ | 55 #endif // MOJO_DATA_PIPE_UTILS_DATA_PIPE_UTILS_H_ |
OLD | NEW |