[email protected] | 6ea6954 | 2010-12-20 18:15:59 | [diff] [blame] | 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 |
| 3 | * found in the LICENSE file. |
| 4 | */ |
[email protected] | 5a3f6285 | 2010-11-10 21:43:01 | [diff] [blame] | 5 | #ifndef PPAPI_C_PPB_URL_REQUEST_INFO_H_ |
| 6 | #define PPAPI_C_PPB_URL_REQUEST_INFO_H_ |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 7 | |
[email protected] | 6f2e391 | 2010-11-05 14:45:44 | [diff] [blame] | 8 | #include "ppapi/c/pp_bool.h" |
[email protected] | 859a7f3 | 2011-01-15 03:44:13 | [diff] [blame] | 9 | #include "ppapi/c/pp_instance.h" |
[email protected] | 1ad2a1db | 2010-12-13 20:04:31 | [diff] [blame] | 10 | #include "ppapi/c/pp_macros.h" |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 11 | #include "ppapi/c/pp_resource.h" |
| 12 | #include "ppapi/c/pp_stdint.h" |
| 13 | #include "ppapi/c/pp_time.h" |
| 14 | |
| 15 | struct PP_Var; |
| 16 | |
[email protected] | 040d5e8 | 2011-01-28 15:38:38 | [diff] [blame] | 17 | /** |
| 18 | * @file |
| 19 | * Defines the API ... |
| 20 | */ |
| 21 | |
| 22 | /** |
| 23 | * |
| 24 | * @addtogroup Enums |
| 25 | * @{ |
| 26 | */ |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 27 | typedef enum { |
| 28 | PP_URLREQUESTPROPERTY_URL, // string |
| 29 | PP_URLREQUESTPROPERTY_METHOD, // string |
| 30 | PP_URLREQUESTPROPERTY_HEADERS, // string, \n-delim |
[email protected] | 6f2e391 | 2010-11-05 14:45:44 | [diff] [blame] | 31 | PP_URLREQUESTPROPERTY_STREAMTOFILE, // PP_Bool (default=PP_FALSE) |
| 32 | PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS, // PP_Bool (default=PP_TRUE) |
[email protected] | 51df0c71 | 2010-11-04 19:39:29 | [diff] [blame] | 33 | |
| 34 | // Set to true if you want to be able to poll the download progress via the |
| 35 | // URLLoader.GetDownloadProgress function. |
| 36 | // |
[email protected] | 6f2e391 | 2010-11-05 14:45:44 | [diff] [blame] | 37 | // Boolean (default = PP_FALSE). |
[email protected] | 51df0c71 | 2010-11-04 19:39:29 | [diff] [blame] | 38 | PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS, |
| 39 | |
| 40 | // Set to true if you want to be able to pull the upload progress via the |
| 41 | // URLLoader.GetUploadProgress function. |
| 42 | // |
[email protected] | 6f2e391 | 2010-11-05 14:45:44 | [diff] [blame] | 43 | // Boolean (default = PP_FALSE). |
[email protected] | 5349184c | 2011-03-14 17:19:49 | [diff] [blame] | 44 | PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS, |
| 45 | |
| 46 | // Set to a String to set a custom referrer (if empty, the referrer header |
| 47 | // will be omitted), or to an Undefined Var to use the default referrer. Only |
| 48 | // loaders with universal access (only available on trusted implementations) |
| 49 | // will accept URLRequestInfo objects which try to set a custom referrer; if |
| 50 | // given to a loader without universal access, PP_ERROR_BADARGUMENT will |
| 51 | // result. |
| 52 | // |
| 53 | // Undefined/String (default = Undefined) |
| 54 | PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL |
[email protected] | 5a3f6285 | 2010-11-10 21:43:01 | [diff] [blame] | 55 | } PP_URLRequestProperty; |
[email protected] | 1ad2a1db | 2010-12-13 20:04:31 | [diff] [blame] | 56 | PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_URLRequestProperty, 4); |
[email protected] | 040d5e8 | 2011-01-28 15:38:38 | [diff] [blame] | 57 | /** |
| 58 | * @} |
| 59 | */ |
[email protected] | 51df0c71 | 2010-11-04 19:39:29 | [diff] [blame] | 60 | |
[email protected] | 859a7f3 | 2011-01-15 03:44:13 | [diff] [blame] | 61 | #define PPB_URLREQUESTINFO_INTERFACE "PPB_URLRequestInfo;0.2" |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 62 | |
[email protected] | 040d5e8 | 2011-01-28 15:38:38 | [diff] [blame] | 63 | /** |
| 64 | * |
| 65 | * @addtogroup Interfaces |
| 66 | * @{ |
| 67 | */ |
[email protected] | 5a3f6285 | 2010-11-10 21:43:01 | [diff] [blame] | 68 | struct PPB_URLRequestInfo { |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 69 | // Create a new URLRequestInfo object. Returns 0 if the module is invalid. |
[email protected] | 859a7f3 | 2011-01-15 03:44:13 | [diff] [blame] | 70 | PP_Resource (*Create)(PP_Instance instance); |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 71 | |
[email protected] | 6f2e391 | 2010-11-05 14:45:44 | [diff] [blame] | 72 | // Returns PP_TRUE if the given resource is an URLRequestInfo. Returns |
| 73 | // PP_FALSE if the resource is invalid or some type other than an |
| 74 | // URLRequestInfo. |
| 75 | PP_Bool (*IsURLRequestInfo)(PP_Resource resource); |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 76 | |
[email protected] | 6f2e391 | 2010-11-05 14:45:44 | [diff] [blame] | 77 | // Sets a request property. Returns PP_FALSE if any of the parameters are |
| 78 | // invalid, PP_TRUE on success. The value property must be the correct type |
| 79 | // according to the property being set. |
| 80 | PP_Bool (*SetProperty)(PP_Resource request, |
[email protected] | 5a3f6285 | 2010-11-10 21:43:01 | [diff] [blame] | 81 | PP_URLRequestProperty property, |
[email protected] | 6f2e391 | 2010-11-05 14:45:44 | [diff] [blame] | 82 | struct PP_Var value); |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 83 | |
| 84 | // Append data to the request body. |
| 85 | // |
| 86 | // A Content-Length request header will be automatically generated. |
| 87 | // |
[email protected] | 6f2e391 | 2010-11-05 14:45:44 | [diff] [blame] | 88 | // Returns PP_FALSE if any of the parameters are invalid, PP_TRUE on success. |
| 89 | PP_Bool (*AppendDataToBody)(PP_Resource request, |
| 90 | const char* data, |
| 91 | uint32_t len); |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 92 | |
| 93 | // Append a file reference to be uploaded. |
| 94 | // |
| 95 | // A sub-range of the file starting from start_offset may be specified. If |
| 96 | // number_of_bytes is -1, then the sub-range to upload extends to the end of |
| 97 | // the file. |
| 98 | // |
| 99 | // An optional (non-zero) last modified time stamp may be provided, which |
| 100 | // will be used to validate that the file was not modified since the given |
| 101 | // time before it is uploaded. The upload will fail with an error code of |
| 102 | // PP_Error_FileChanged if the file has been modified since the given time. |
| 103 | // If expected_last_modified_time is 0, then no validation is performed. |
| 104 | // |
| 105 | // A Content-Length request header will be automatically generated. |
| 106 | // |
[email protected] | 6f2e391 | 2010-11-05 14:45:44 | [diff] [blame] | 107 | // Returns PP_FALSE if any of the parameters are invalid, PP_TRUE on success. |
| 108 | PP_Bool (*AppendFileToBody)(PP_Resource request, |
| 109 | PP_Resource file_ref, |
| 110 | int64_t start_offset, |
| 111 | int64_t number_of_bytes, |
| 112 | PP_Time expected_last_modified_time); |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 113 | }; |
[email protected] | 040d5e8 | 2011-01-28 15:38:38 | [diff] [blame] | 114 | /** |
| 115 | * @} |
| 116 | */ |
[email protected] | 1758e88 | 2010-11-01 16:16:50 | [diff] [blame] | 117 | |
[email protected] | 6ea6954 | 2010-12-20 18:15:59 | [diff] [blame] | 118 | #endif /* PPAPI_C_PPB_URL_REQUEST_INFO_H_ */ |
| 119 | |