1 // Copyright 2013 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 LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_NODE_H_
6 #define LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_NODE_H_
12 #include "nacl_io/error.h"
13 #include "nacl_io/node.h"
14 #include "nacl_io/pepper_interface.h"
18 typedef std::map<std::string, std::string> StringMap_t;
20 class HttpFsNode : public Node {
22 virtual Error FSync();
23 virtual Error GetDents(size_t offs,
27 virtual Error GetStat(struct stat* stat);
28 virtual Error Read(const HandleAttr& attr,
32 virtual Error FTruncate(off_t size);
33 virtual Error Write(const HandleAttr& attr,
37 virtual Error GetSize(off_t* out_size);
39 void SetCachedSize(off_t size);
40 void SetMode(int mode);
43 HttpFsNode(Filesystem* filesystem,
44 const std::string& url,
48 Error GetStat_Locked(struct stat* stat);
49 Error OpenUrl(const char* method,
50 StringMap_t* request_headers,
51 ScopedResource* out_loader,
52 ScopedResource* out_request,
53 ScopedResource* out_response,
54 int32_t* out_statuscode,
55 StringMap_t* out_response_headers);
57 Error DownloadToCache();
58 Error ReadPartialFromCache(const HandleAttr& attr,
62 Error DownloadPartial(const HandleAttr& attr,
67 Error DownloadToTemp(off_t* out_bytes);
69 // Read as much as possible from |loader|, using |buffer_| as a scratch area.
70 Error ReadEntireResponseToTemp(const ScopedResource& loader,
72 // Read as much as possible from |loader|, storing the result in
74 Error ReadEntireResponseToCache(const ScopedResource& loader, int* out_bytes);
76 // Read up to |count| bytes from |loader|, using |buffer_| as a scratch area.
77 Error ReadResponseToTemp(const ScopedResource& loader,
81 // Read up to |count| bytes from |loader|, and store the result in |buf|,
82 // which is assumed to have |count| bytes free.
83 Error ReadResponseToBuffer(const ScopedResource& loader,
89 std::vector<char> buffer_;
92 bool has_cached_size_;
93 std::vector<char> cached_data_;
98 } // namespace nacl_io
100 #endif // LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_NODE_H_