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
);
42 HttpFsNode(Filesystem
* filesystem
,
43 const std::string
& url
,
46 virtual ~HttpFsNode();
49 Error
GetStat_Locked(struct stat
* stat
);
50 Error
OpenUrl(const char* method
,
51 StringMap_t
* request_headers
,
52 ScopedResource
* out_loader
,
53 ScopedResource
* out_request
,
54 ScopedResource
* out_response
,
55 int32_t* out_statuscode
,
56 StringMap_t
* out_response_headers
);
58 Error
DownloadToCache();
59 Error
ReadPartialFromCache(const HandleAttr
& attr
,
63 Error
DownloadPartial(const HandleAttr
& attr
,
68 Error
DownloadToTemp(off_t
* out_bytes
);
70 // Read as much as possible from |loader|, using |buffer_| as a scratch area.
71 Error
ReadEntireResponseToTemp(const ScopedResource
& loader
,
73 // Read as much as possible from |loader|, storing the result in
75 Error
ReadEntireResponseToCache(const ScopedResource
& loader
, int* out_bytes
);
77 // Read up to |count| bytes from |loader|, using |buffer_| as a scratch area.
78 Error
ReadResponseToTemp(const ScopedResource
& loader
,
82 // Read up to |count| bytes from |loader|, and store the result in |buf|,
83 // which is assumed to have |count| bytes free.
84 Error
ReadResponseToBuffer(const ScopedResource
& loader
,
94 bool has_cached_size_
;
95 std::vector
<char> cached_data_
;
100 } // namespace nacl_io
102 #endif // LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_NODE_H_