OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 PPAPI_CPP_DEV_URL_LOADER_DEV_H_ | 5 #ifndef PPAPI_CPP_URL_LOADER_H_ |
6 #define PPAPI_CPP_DEV_URL_LOADER_DEV_H_ | 6 #define PPAPI_CPP_URL_LOADER_H_ |
7 | 7 |
8 #include "ppapi/c/pp_stdint.h" | 8 #include "ppapi/c/pp_stdint.h" |
9 #include "ppapi/cpp/resource.h" | 9 #include "ppapi/cpp/resource.h" |
10 | 10 |
11 namespace pp { | 11 namespace pp { |
12 | 12 |
13 class CompletionCallback; | 13 class CompletionCallback; |
14 class Instance; | 14 class Instance; |
15 class URLRequestInfo_Dev; | 15 class URLRequestInfo; |
16 class URLResponseInfo_Dev; | 16 class URLResponseInfo; |
17 | 17 |
18 // URLLoader provides an API to download URLs. | 18 // URLLoader provides an API to download URLs. |
19 // | 19 // |
20 // EXAMPLE USAGE: | 20 // EXAMPLE USAGE: |
21 // | 21 // |
22 // class MyHandler { | 22 // class MyHandler { |
23 // public: | 23 // public: |
24 // MyHandler(const Instance& instance) | 24 // MyHandler(const Instance& instance) |
25 // : factory_(this), | 25 // : factory_(this), |
26 // loader_(instance), | 26 // loader_(instance), |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // } | 68 // } |
69 // void ProcessBytes(const char* bytes, int32_t length) { | 69 // void ProcessBytes(const char* bytes, int32_t length) { |
70 // // Do work ... | 70 // // Do work ... |
71 // } | 71 // } |
72 // pp::CompletionCallbackFactory<MyHandler> factory_; | 72 // pp::CompletionCallbackFactory<MyHandler> factory_; |
73 // pp::URLLoader loader_; | 73 // pp::URLLoader loader_; |
74 // char buf_[4096]; | 74 // char buf_[4096]; |
75 // bool did_open_; | 75 // bool did_open_; |
76 // }; | 76 // }; |
77 // | 77 // |
78 class URLLoader_Dev : public Resource { | 78 class URLLoader : public Resource { |
79 public: | 79 public: |
80 // Creates an is_null() URLLoader object. | 80 // Creates an is_null() URLLoader object. |
81 URLLoader_Dev() {} | 81 URLLoader() {} |
82 | 82 |
83 explicit URLLoader_Dev(PP_Resource resource); | 83 explicit URLLoader(PP_Resource resource); |
84 explicit URLLoader_Dev(const Instance& instance); | 84 explicit URLLoader(const Instance& instance); |
85 URLLoader_Dev(const URLLoader_Dev& other); | 85 URLLoader(const URLLoader& other); |
86 | |
87 URLLoader_Dev& operator=(const URLLoader_Dev& other); | |
88 void swap(URLLoader_Dev& other); | |
89 | 86 |
90 // PPB_URLLoader methods: | 87 // PPB_URLLoader methods: |
91 int32_t Open(const URLRequestInfo_Dev& request_info, | 88 int32_t Open(const URLRequestInfo& request_info, |
92 const CompletionCallback& cc); | 89 const CompletionCallback& cc); |
93 int32_t FollowRedirect(const CompletionCallback& cc); | 90 int32_t FollowRedirect(const CompletionCallback& cc); |
94 bool GetUploadProgress(int64_t* bytes_sent, | 91 bool GetUploadProgress(int64_t* bytes_sent, |
95 int64_t* total_bytes_to_be_sent) const; | 92 int64_t* total_bytes_to_be_sent) const; |
96 bool GetDownloadProgress(int64_t* bytes_received, | 93 bool GetDownloadProgress(int64_t* bytes_received, |
97 int64_t* total_bytes_to_be_received) const; | 94 int64_t* total_bytes_to_be_received) const; |
98 URLResponseInfo_Dev GetResponseInfo() const; | 95 URLResponseInfo GetResponseInfo() const; |
99 int32_t ReadResponseBody(char* buffer, | 96 int32_t ReadResponseBody(char* buffer, |
100 int32_t bytes_to_read, | 97 int32_t bytes_to_read, |
101 const CompletionCallback& cc); | 98 const CompletionCallback& cc); |
102 int32_t FinishStreamingToFile(const CompletionCallback& cc); | 99 int32_t FinishStreamingToFile(const CompletionCallback& cc); |
103 void Close(); | 100 void Close(); |
104 }; | 101 }; |
105 | 102 |
106 } // namespace pp | 103 } // namespace pp |
107 | 104 |
108 #endif // PPAPI_CPP_DEV_URL_LOADER_DEV_H_ | 105 #endif // PPAPI_CPP_URL_LOADER_H_ |
OLD | NEW |