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_
10 #include "base/callback_forward.h"
11 #include "mojo/common/mojo_common_export.h"
12 #include "mojo/public/cpp/system/core.h"
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 // 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
33 // be read from source before the error occurred.
34 bool MOJO_COMMON_EXPORT
BlockingCopyToString(
35 ScopedDataPipeConsumerHandle source
,
36 std::string
* contents
);
41 #endif // MOJO_SHELL_DATA_PIPE_UTILS_H_