| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_NODE_H_ | 5 #ifndef LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_NODE_H_ |
| 6 #define LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_NODE_H_ | 6 #define LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_NODE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 virtual Error GetStat(struct stat* stat); | 27 virtual Error GetStat(struct stat* stat); |
| 28 virtual Error Read(const HandleAttr& attr, | 28 virtual Error Read(const HandleAttr& attr, |
| 29 void* buf, | 29 void* buf, |
| 30 size_t count, | 30 size_t count, |
| 31 int* out_bytes); | 31 int* out_bytes); |
| 32 virtual Error FTruncate(off_t size); | 32 virtual Error FTruncate(off_t size); |
| 33 virtual Error Write(const HandleAttr& attr, | 33 virtual Error Write(const HandleAttr& attr, |
| 34 const void* buf, | 34 const void* buf, |
| 35 size_t count, | 35 size_t count, |
| 36 int* out_bytes); | 36 int* out_bytes); |
| 37 virtual Error GetSize(size_t* out_size); | 37 virtual Error GetSize(off_t* out_size); |
| 38 | 38 |
| 39 void SetCachedSize(off_t size); | 39 void SetCachedSize(off_t size); |
| 40 void SetMode(int mode); | 40 void SetMode(int mode); |
| 41 | 41 |
| 42 protected: | 42 protected: |
| 43 HttpFsNode(Filesystem* filesystem, | 43 HttpFsNode(Filesystem* filesystem, |
| 44 const std::string& url, | 44 const std::string& url, |
| 45 bool cache_content); | 45 bool cache_content); |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 Error GetStat_Locked(struct stat* stat); | 48 Error GetStat_Locked(struct stat* stat); |
| 49 Error OpenUrl(const char* method, | 49 Error OpenUrl(const char* method, |
| 50 StringMap_t* request_headers, | 50 StringMap_t* request_headers, |
| 51 ScopedResource* out_loader, | 51 ScopedResource* out_loader, |
| 52 ScopedResource* out_request, | 52 ScopedResource* out_request, |
| 53 ScopedResource* out_response, | 53 ScopedResource* out_response, |
| 54 int32_t* out_statuscode, | 54 int32_t* out_statuscode, |
| 55 StringMap_t* out_response_headers); | 55 StringMap_t* out_response_headers); |
| 56 | 56 |
| 57 Error DownloadToCache(); | 57 Error DownloadToCache(); |
| 58 Error ReadPartialFromCache(const HandleAttr& attr, | 58 Error ReadPartialFromCache(const HandleAttr& attr, |
| 59 void* buf, | 59 void* buf, |
| 60 int count, | 60 int count, |
| 61 int* out_bytes); | 61 int* out_bytes); |
| 62 Error DownloadPartial(const HandleAttr& attr, | 62 Error DownloadPartial(const HandleAttr& attr, |
| 63 void* buf, | 63 void* buf, |
| 64 size_t count, | 64 size_t count, |
| 65 int* out_bytes); | 65 int* out_bytes); |
| 66 | 66 |
| 67 Error DownloadToTemp(int* out_bytes); | 67 Error DownloadToTemp(off_t* out_bytes); |
| 68 | 68 |
| 69 // Read as much as possible from |loader|, using |buffer_| as a scratch area. | 69 // Read as much as possible from |loader|, using |buffer_| as a scratch area. |
| 70 Error ReadEntireResponseToTemp(const ScopedResource& loader, int* out_bytes); | 70 Error ReadEntireResponseToTemp(const ScopedResource& loader, |
| 71 off_t* out_bytes); |
| 71 // Read as much as possible from |loader|, storing the result in | 72 // Read as much as possible from |loader|, storing the result in |
| 72 // |cached_data_|. | 73 // |cached_data_|. |
| 73 Error ReadEntireResponseToCache(const ScopedResource& loader, int* out_bytes); | 74 Error ReadEntireResponseToCache(const ScopedResource& loader, int* out_bytes); |
| 74 | 75 |
| 75 // Read up to |count| bytes from |loader|, using |buffer_| as a scratch area. | 76 // Read up to |count| bytes from |loader|, using |buffer_| as a scratch area. |
| 76 Error ReadResponseToTemp(const ScopedResource& loader, | 77 Error ReadResponseToTemp(const ScopedResource& loader, |
| 77 int count, | 78 int count, |
| 78 int* out_bytes); | 79 int* out_bytes); |
| 79 | 80 |
| 80 // Read up to |count| bytes from |loader|, and store the result in |buf|, | 81 // Read up to |count| bytes from |loader|, and store the result in |buf|, |
| 81 // which is assumed to have |count| bytes free. | 82 // which is assumed to have |count| bytes free. |
| 82 Error ReadResponseToBuffer(const ScopedResource& loader, | 83 Error ReadResponseToBuffer(const ScopedResource& loader, |
| 83 void* buf, | 84 void* buf, |
| 84 int count, | 85 int count, |
| 85 int* out_bytes); | 86 int* out_bytes); |
| 86 | 87 |
| 87 std::string url_; | 88 std::string url_; |
| 88 std::vector<char> buffer_; | 89 std::vector<char> buffer_; |
| 89 | 90 |
| 90 bool cache_content_; | 91 bool cache_content_; |
| 91 bool has_cached_size_; | 92 bool has_cached_size_; |
| 92 std::vector<char> cached_data_; | 93 std::vector<char> cached_data_; |
| 93 | 94 |
| 94 friend class HttpFs; | 95 friend class HttpFs; |
| 95 }; | 96 }; |
| 96 | 97 |
| 97 } // namespace nacl_io | 98 } // namespace nacl_io |
| 98 | 99 |
| 99 #endif // LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_NODE_H_ | 100 #endif // LIBRARIES_NACL_IO_HTTPFS_HTTP_FS_NODE_H_ |
| OLD | NEW |