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