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_PUBLIC_CPP_SYSTEM_DATA_PIPE_UTILS_H_ 6 #define MOJO_PUBLIC_CPP_SYSTEM_DATA_PIPE_UTILS_H_ 7 8 #include <stdint.h> 9 10 #include <string> 11 12 #include "mojo/public/cpp/system/data_pipe.h" 13 #include "mojo/public/cpp/system/system_export.h" 14 15 namespace mojo { 16 17 // Copies the data from |source| into |contents| and returns true on success and 18 // false on error. In case of I/O error, |contents| holds the data that could 19 // be read from source before the error occurred. 20 bool MOJO_CPP_SYSTEM_EXPORT 21 BlockingCopyToString(ScopedDataPipeConsumerHandle source, 22 std::string* contents); 23 24 bool MOJO_CPP_SYSTEM_EXPORT 25 BlockingCopyFromString(const std::string& source, 26 const ScopedDataPipeProducerHandle& destination); 27 28 } // namespace mojo 29 30 #endif // MOJO_PUBLIC_CPP_SYSTEM_DATA_PIPE_UTILS_H_ 31