#ifndef MOJO_PUBLIC_CPP_SYSTEM_STRING_DATA_SOURCE_H_
#define MOJO_PUBLIC_CPP_SYSTEM_STRING_DATA_SOURCE_H_
#include <string>
#include "base/containers/span.h"
#include "mojo/public/cpp/system/data_pipe_producer.h"
#include "mojo/public/cpp/system/system_export.h"
namespace mojo {
class MOJO_CPP_SYSTEM_EXPORT StringDataSource final
: public DataPipeProducer::DataSource {
public:
enum class AsyncWritingMode {
STRING_MAY_BE_INVALIDATED_BEFORE_COMPLETION,
STRING_STAYS_VALID_UNTIL_COMPLETION
};
StringDataSource(base::span<const char> data, AsyncWritingMode mode);
StringDataSource(const StringDataSource&) = delete;
StringDataSource& operator=(const StringDataSource&) = delete;
~StringDataSource() override;
private:
uint64_t GetLength() const override;
ReadResult Read(uint64_t offset, base::span<char> buffer) override;
std::string data_;
base::span<const char> data_view_;
};
}
#endif