blob: 441a02ca3622b0b037d5d87034f54cf99e38bd17 [file] [log] [blame]
[email protected]6ea69542010-12-20 18:15:591/* 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]5a3f62852010-11-10 21:43:015#ifndef PPAPI_C_PPB_URL_REQUEST_INFO_H_
6#define PPAPI_C_PPB_URL_REQUEST_INFO_H_
[email protected]1758e882010-11-01 16:16:507
[email protected]6f2e3912010-11-05 14:45:448#include "ppapi/c/pp_bool.h"
[email protected]859a7f32011-01-15 03:44:139#include "ppapi/c/pp_instance.h"
[email protected]1ad2a1db2010-12-13 20:04:3110#include "ppapi/c/pp_macros.h"
[email protected]1758e882010-11-01 16:16:5011#include "ppapi/c/pp_resource.h"
12#include "ppapi/c/pp_stdint.h"
13#include "ppapi/c/pp_time.h"
14
15struct PP_Var;
16
[email protected]040d5e82011-01-28 15:38:3817/**
18 * @file
19 * Defines the API ...
20 */
21
22/**
23 *
24 * @addtogroup Enums
25 * @{
26 */
[email protected]1758e882010-11-01 16:16:5027typedef enum {
28 PP_URLREQUESTPROPERTY_URL, // string
29 PP_URLREQUESTPROPERTY_METHOD, // string
30 PP_URLREQUESTPROPERTY_HEADERS, // string, \n-delim
[email protected]6f2e3912010-11-05 14:45:4431 PP_URLREQUESTPROPERTY_STREAMTOFILE, // PP_Bool (default=PP_FALSE)
32 PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS, // PP_Bool (default=PP_TRUE)
[email protected]51df0c712010-11-04 19:39:2933
34 // Set to true if you want to be able to poll the download progress via the
35 // URLLoader.GetDownloadProgress function.
36 //
[email protected]6f2e3912010-11-05 14:45:4437 // Boolean (default = PP_FALSE).
[email protected]51df0c712010-11-04 19:39:2938 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]6f2e3912010-11-05 14:45:4443 // Boolean (default = PP_FALSE).
[email protected]5349184c2011-03-14 17:19:4944 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]5a3f62852010-11-10 21:43:0155} PP_URLRequestProperty;
[email protected]1ad2a1db2010-12-13 20:04:3156PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_URLRequestProperty, 4);
[email protected]040d5e82011-01-28 15:38:3857/**
58 * @}
59 */
[email protected]51df0c712010-11-04 19:39:2960
[email protected]859a7f32011-01-15 03:44:1361#define PPB_URLREQUESTINFO_INTERFACE "PPB_URLRequestInfo;0.2"
[email protected]1758e882010-11-01 16:16:5062
[email protected]040d5e82011-01-28 15:38:3863/**
64 *
65 * @addtogroup Interfaces
66 * @{
67 */
[email protected]5a3f62852010-11-10 21:43:0168struct PPB_URLRequestInfo {
[email protected]1758e882010-11-01 16:16:5069 // Create a new URLRequestInfo object. Returns 0 if the module is invalid.
[email protected]859a7f32011-01-15 03:44:1370 PP_Resource (*Create)(PP_Instance instance);
[email protected]1758e882010-11-01 16:16:5071
[email protected]6f2e3912010-11-05 14:45:4472 // 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]1758e882010-11-01 16:16:5076
[email protected]6f2e3912010-11-05 14:45:4477 // 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]5a3f62852010-11-10 21:43:0181 PP_URLRequestProperty property,
[email protected]6f2e3912010-11-05 14:45:4482 struct PP_Var value);
[email protected]1758e882010-11-01 16:16:5083
84 // Append data to the request body.
85 //
86 // A Content-Length request header will be automatically generated.
87 //
[email protected]6f2e3912010-11-05 14:45:4488 // 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]1758e882010-11-01 16:16:5092
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]6f2e3912010-11-05 14:45:44107 // 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]1758e882010-11-01 16:16:50113};
[email protected]040d5e82011-01-28 15:38:38114/**
115 * @}
116 */
[email protected]1758e882010-11-01 16:16:50117
[email protected]6ea69542010-12-20 18:15:59118#endif /* PPAPI_C_PPB_URL_REQUEST_INFO_H_ */
119