| Index: native_client_sdk/src/libraries/nacl_io/mount_node_http.h
|
| diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_http.h b/native_client_sdk/src/libraries/nacl_io/mount_node_http.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6b174681d11ec7a927f69ec826667fab6fe7cd6b
|
| --- /dev/null
|
| +++ b/native_client_sdk/src/libraries/nacl_io/mount_node_http.h
|
| @@ -0,0 +1,70 @@
|
| +/* Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| + * Use of this source code is governed by a BSD-style license that can be
|
| + * found in the LICENSE file.
|
| + */
|
| +
|
| +#ifndef LIBRARIES_NACL_IO_MOUNT_NODE_HTTP_H_
|
| +#define LIBRARIES_NACL_IO_MOUNT_NODE_HTTP_H_
|
| +
|
| +#include <map>
|
| +#include <string>
|
| +#include <vector>
|
| +
|
| +#include "nacl_io/error.h"
|
| +#include "nacl_io/mount_node.h"
|
| +#include "nacl_io/pepper_interface.h"
|
| +
|
| +typedef std::map<std::string, std::string> StringMap_t;
|
| +
|
| +class MountNodeHttp : public MountNode {
|
| + public:
|
| + virtual Error FSync();
|
| + virtual Error GetDents(size_t offs,
|
| + struct dirent* pdir,
|
| + size_t count,
|
| + int* out_bytes);
|
| + virtual Error GetStat(struct stat* stat);
|
| + virtual Error Read(size_t offs, void* buf, size_t count, int* out_bytes);
|
| + virtual Error FTruncate(off_t size);
|
| + virtual Error Write(size_t offs,
|
| + const void* buf,
|
| + size_t count,
|
| + int* out_bytes);
|
| + virtual Error GetSize(size_t* out_size);
|
| +
|
| + void SetCachedSize(off_t size);
|
| +
|
| + protected:
|
| + MountNodeHttp(Mount* mount, const std::string& url, bool cache_content);
|
| +
|
| + private:
|
| + Error OpenUrl(const char* method,
|
| + StringMap_t* request_headers,
|
| + PP_Resource* out_loader,
|
| + PP_Resource* out_request,
|
| + PP_Resource* out_response,
|
| + int32_t* out_statuscode,
|
| + StringMap_t* out_response_headers);
|
| +
|
| + Error DownloadToCache();
|
| + Error ReadPartialFromCache(size_t offs,
|
| + void* buf,
|
| + size_t count,
|
| + int* out_bytes);
|
| + Error DownloadPartial(size_t offs, void* buf, size_t count, int* out_bytes);
|
| + Error DownloadToBuffer(PP_Resource loader,
|
| + void* buf,
|
| + size_t count,
|
| + int* out_bytes);
|
| +
|
| + std::string url_;
|
| + std::vector<char> buffer_;
|
| +
|
| + bool cache_content_;
|
| + bool has_cached_size_;
|
| + std::vector<char> cached_data_;
|
| +
|
| + friend class MountHttp;
|
| +};
|
| +
|
| +#endif // LIBRARIES_NACL_IO_MOUNT_NODE_HTTP_H_
|
|
|