Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: mojo/data_pipe_utils/data_pipe_utils.h

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/data_pipe_utils/data_pipe_file_utils.cc ('k') | mojo/data_pipe_utils/data_pipe_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MOJO_DATA_PIPE_UTILS_DATA_PIPE_UTILS_H_
6 #define MOJO_DATA_PIPE_UTILS_DATA_PIPE_UTILS_H_
7
8 #include <stdio.h>
9 #include <string>
10
11 #include "base/callback_forward.h"
12 #include "base/files/scoped_file.h"
13 #include "base/threading/platform_thread.h"
14 #include "mojo/public/cpp/system/data_pipe.h"
15
16 namespace base {
17 class FilePath;
18 class TaskRunner;
19 }
20
21 namespace mojo {
22 namespace common {
23
24 // Asynchronously copies data from source to the destination file. The given
25 // |callback| is run upon completion. File writes will be scheduled to the
26 // given |task_runner|.
27 void CopyToFile(ScopedDataPipeConsumerHandle source,
28 const base::FilePath& destination,
29 base::TaskRunner* task_runner,
30 const base::Callback<void(bool /*success*/)>& callback);
31
32 void CopyFromFile(const base::FilePath& source,
33 ScopedDataPipeProducerHandle destination,
34 uint32_t skip,
35 base::TaskRunner* task_runner,
36 const base::Callback<void(bool /*success*/)>& callback);
37
38 // Copies the data from |source| into |contents| and returns true on success and
39 // false on error. In case of I/O error, |contents| holds the data that could
40 // be read from source before the error occurred.
41 bool BlockingCopyToString(ScopedDataPipeConsumerHandle source,
42 std::string* contents);
43
44 bool BlockingCopyFromString(const std::string& source,
45 const ScopedDataPipeProducerHandle& destination);
46
47 // Synchronously copies source data to a temporary file, returning a file
48 // pointer on success and NULL on error. The temporary file is unlinked
49 // immediately so that it is only accessible by file pointer (and removed once
50 // closed or the creating process dies).
51 base::ScopedFILE BlockingCopyToTempFile(ScopedDataPipeConsumerHandle source);
52
53 // Similar to BlockingCopyToTempFile, but use a pre-defined file pointer
54 // (rather than a newly created temp file) and do not unlink the file.
55 // Returns true on success, false on failure.
56 bool BlockingCopyToFile(ScopedDataPipeConsumerHandle source, FILE* fp);
57
58 // Copies the string |contents| to a temporary data pipe and returns the
59 // consumer handle.
60 ScopedDataPipeConsumerHandle WriteStringToConsumerHandle(
61 const std::string& source);
62
63 } // namespace common
64 } // namespace mojo
65
66 #endif // MOJO_DATA_PIPE_UTILS_DATA_PIPE_UTILS_H_
OLDNEW
« no previous file with comments | « mojo/data_pipe_utils/data_pipe_file_utils.cc ('k') | mojo/data_pipe_utils/data_pipe_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698