file_stream_test_utils.h 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2019 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. #ifndef STORAGE_BROWSER_FILE_SYSTEM_FILE_STREAM_TEST_UTILS_H_
  5. #define STORAGE_BROWSER_FILE_SYSTEM_FILE_STREAM_TEST_UTILS_H_
  6. #include <string>
  7. namespace storage {
  8. class FileStreamReader;
  9. class FileStreamWriter;
  10. // Reads upto |size| bytes of data from |reader|, an initialized
  11. // FileStreamReader. The read bytes will be written to |data| and the actual
  12. // number of bytes or the error code will be written to |result|.
  13. void ReadFromReader(FileStreamReader* reader,
  14. std::string* data,
  15. size_t size,
  16. int* result);
  17. // Returns the length of the file if it could be successfully retrieved,
  18. // otherwise a net error.
  19. int64_t GetLengthFromReader(FileStreamReader* reader);
  20. // Writes |data| to |writer|, an initialized FileStreamWriter. Returns net::OK
  21. // if successful, otherwise a net error.
  22. int WriteStringToWriter(FileStreamWriter* writer, const std::string& data);
  23. } // namespace storage
  24. #endif // STORAGE_BROWSER_FILE_SYSTEM_FILE_STREAM_TEST_UTILS_H_