Roll src/third_party/skia d32087a:1052f51
[chromium-blink-merge.git] / mojo / common / data_pipe_utils.h
blob5b32cfd8b92f6bca13c652d2498ba6e7cd178a7c
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.
5 #ifndef MOJO_SHELL_DATA_PIPE_UTILS_H_
6 #define MOJO_SHELL_DATA_PIPE_UTILS_H_
8 #include <string>
10 #include "base/callback_forward.h"
11 #include "mojo/common/mojo_common_export.h"
12 #include "third_party/mojo/src/mojo/public/cpp/system/core.h"
14 namespace base {
15 class FilePath;
16 class TaskRunner;
19 namespace mojo {
20 namespace common {
22 // Asynchronously copies data from source to the destination file. The given
23 // |callback| is run upon completion. File writes will be scheduled to the
24 // given |task_runner|.
25 void MOJO_COMMON_EXPORT CopyToFile(
26 ScopedDataPipeConsumerHandle source,
27 const base::FilePath& destination,
28 base::TaskRunner* task_runner,
29 const base::Callback<void(bool /*success*/)>& callback);
31 void MOJO_COMMON_EXPORT
32 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);
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 MOJO_COMMON_EXPORT BlockingCopyToString(
42 ScopedDataPipeConsumerHandle source,
43 std::string* contents);
45 bool MOJO_COMMON_EXPORT BlockingCopyFromString(
46 const std::string& source,
47 const ScopedDataPipeProducerHandle& destination);
49 // Synchronously copies data from source to the destination file returning true
50 // on success and false on error. In case of an error, |destination| holds the
51 // data that could be read from the source before the error occured.
52 bool MOJO_COMMON_EXPORT BlockingCopyToFile(ScopedDataPipeConsumerHandle source,
53 const base::FilePath& destination);
55 } // namespace common
56 } // namespace mojo
58 #endif // MOJO_SHELL_DATA_PIPE_UTILS_H_