Pepper_56_C++_interfaces
Pepper_56_C++_interfaces
 All Classes Namespaces Files Functions Typedefs Enumerations Macros Groups
url_request_info.h
Go to the documentation of this file.
1 // Copyright (c) 2012 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.
4 
5 #ifndef PPAPI_CPP_URL_REQUEST_INFO_H_
6 #define PPAPI_CPP_URL_REQUEST_INFO_H_
7 
8 #include <stdint.h>
9 
10 #include "ppapi/c/ppb_url_request_info.h"
11 #include "ppapi/cpp/resource.h"
12 #include "ppapi/cpp/var.h"
13 
16 namespace pp {
17 
18 class FileRef;
19 class InstanceHandle;
20 
22 class URLRequestInfo : public Resource {
23  public:
27 
34  explicit URLRequestInfo(const InstanceHandle& instance);
35 
39  URLRequestInfo(const URLRequestInfo& other);
40 
50  bool SetProperty(PP_URLRequestProperty property, const Var& value);
51 
60  bool AppendDataToBody(const void* data, uint32_t len);
61 
68 
78  bool AppendFileToBody(const FileRef& file_ref,
79  PP_Time expected_last_modified_time = 0);
80 
101  bool AppendFileRangeToBody(const FileRef& file_ref,
102  int64_t start_offset,
103  int64_t length,
104  PP_Time expected_last_modified_time = 0);
105 
112  bool SetURL(const Var& url_string) {
113  return SetProperty(PP_URLREQUESTPROPERTY_URL, url_string);
114  }
115 
126  bool SetMethod(const Var& method_string) {
127  return SetProperty(PP_URLREQUESTPROPERTY_METHOD, method_string);
128  }
129 
141  bool SetHeaders(const Var& headers_string) {
142  return SetProperty(PP_URLREQUESTPROPERTY_HEADERS, headers_string);
143  }
144 
155  bool SetStreamToFile(bool enable) {
156  return SetProperty(PP_URLREQUESTPROPERTY_STREAMTOFILE, enable);
157  }
158 
169  bool SetFollowRedirects(bool enable) {
170  return SetProperty(PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS, enable);
171  }
172 
183  bool SetRecordDownloadProgress(bool enable) {
184  return SetProperty(PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS, enable);
185  }
186 
196  bool SetRecordUploadProgress(bool enable) {
197  return SetProperty(PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS, enable);
198  }
199 
214  bool SetCustomReferrerURL(const Var& url) {
215  return SetProperty(PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL, url);
216  }
217 
231  bool SetAllowCrossOriginRequests(bool enable) {
232  return SetProperty(PP_URLREQUESTPROPERTY_ALLOWCROSSORIGINREQUESTS, enable);
233  }
234 
246  bool SetAllowCredentials(bool enable) {
247  return SetProperty(PP_URLREQUESTPROPERTY_ALLOWCREDENTIALS, enable);
248  }
249 
266  bool SetCustomContentTransferEncoding(const Var& content_transfer_encoding) {
267  return SetProperty(PP_URLREQUESTPROPERTY_CUSTOMCONTENTTRANSFERENCODING,
268  content_transfer_encoding);
269  }
270 
287  bool SetPrefetchBufferUpperThreshold(int32_t size) {
288  return SetProperty(PP_URLREQUESTPROPERTY_PREFETCHBUFFERUPPERTHRESHOLD,
289  size);
290  }
291 
309  bool SetPrefetchBufferLowerThreshold(int32_t size) {
310  return SetProperty(PP_URLREQUESTPROPERTY_PREFETCHBUFFERLOWERTHRESHOLD,
311  size);
312  }
313 
329  bool SetCustomUserAgent(const Var& user_agent) {
330  return SetProperty(PP_URLREQUESTPROPERTY_CUSTOMUSERAGENT, user_agent);
331  }
332 };
333 
334 } // namespace pp
335 
336 #endif // PPAPI_CPP_URL_REQUEST_INFO_H_
bool SetStreamToFile(bool enable)
Definition: url_request_info.h:155
Definition: file_ref.h:27
bool SetAllowCredentials(bool enable)
Definition: url_request_info.h:246
bool SetPrefetchBufferLowerThreshold(int32_t size)
Definition: url_request_info.h:309
bool SetFollowRedirects(bool enable)
Definition: url_request_info.h:169
URLRequestInfo()
Definition: url_request_info.h:26
bool AppendFileRangeToBody(const FileRef &file_ref, int64_t start_offset, int64_t length, PP_Time expected_last_modified_time=0)
bool SetHeaders(const Var &headers_string)
Definition: url_request_info.h:141
Definition: instance_handle.h:44
bool SetCustomReferrerURL(const Var &url)
Definition: url_request_info.h:214
bool SetAllowCrossOriginRequests(bool enable)
Definition: url_request_info.h:231
bool AppendFileToBody(const FileRef &file_ref, PP_Time expected_last_modified_time=0)
bool SetCustomContentTransferEncoding(const Var &content_transfer_encoding)
Definition: url_request_info.h:266
bool SetCustomUserAgent(const Var &user_agent)
Definition: url_request_info.h:329
bool SetRecordUploadProgress(bool enable)
Definition: url_request_info.h:196
bool SetPrefetchBufferUpperThreshold(int32_t size)
Definition: url_request_info.h:287
bool SetRecordDownloadProgress(bool enable)
Definition: url_request_info.h:183
URLRequestInfo provides an API for creating and manipulating URL requests.
Definition: url_request_info.h:22
bool SetMethod(const Var &method_string)
Definition: url_request_info.h:126
bool AppendDataToBody(const void *data, uint32_t len)
A generic type used for passing data types between the module and the page.
Definition: var.h:23
bool SetProperty(PP_URLRequestProperty property, const Var &value)
A reference counted module resource.
Definition: resource.h:20
bool SetURL(const Var &url_string)
Definition: url_request_info.h:112