1 // Copyright (c) 2011 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.
5 #ifndef PPAPI_CPP_URL_RESPONSE_INFO_H_
6 #define PPAPI_CPP_URL_RESPONSE_INFO_H_
8 #include "ppapi/c/ppb_url_response_info.h"
9 #include "ppapi/cpp/resource.h"
10 #include "ppapi/cpp/var.h"
13 /// This file defines the API for examining URL responses.
18 /// URLResponseInfo provides an API for examining URL responses.
19 class URLResponseInfo
: public Resource
{
21 /// Default constructor. This constructor creates an <code>is_null</code>
25 /// A constructor used when you have received a <code>PP_Resource</code> as a
26 /// return value that has already been reference counted.
28 /// @param[in] resource A <code>PP_Resource</code> corresponding to a
30 URLResponseInfo(PassRef
, PP_Resource resource
);
32 /// The copy constructor for <code>URLResponseInfo</code>.
33 URLResponseInfo(const URLResponseInfo
& other
);
35 /// This function gets a response property.
37 /// @param[in] property A <code>PP_URLResponseProperty</code> identifying the
38 /// type of property in the response.
40 /// @return A <code>Var</code> containing the response property value if
41 /// successful, <code>is_undefined Var</code> if an input parameter is
43 Var
GetProperty(PP_URLResponseProperty property
) const;
45 /// This function returns a <code>FileRef</code>
46 /// pointing to the file containing the response body. This
47 /// is only valid if <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> was set
48 /// on the <code>URLRequestInfo</code> used to produce this response. This
49 /// file remains valid until the <code>URLLoader</code> associated with this
50 /// <code>URLResponseInfo</code> is closed or destroyed.
52 /// @return A <code>FileRef</code> corresponding to a
53 /// <code>FileRef</code> if successful, an <code>is_null</code> object if
54 /// <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> was not requested or if
55 /// the <code>URLLoader</code> has not been opened yet.
56 FileRef
GetBodyAsFileRef() const;
58 /// This function gets the <code>PP_URLRESPONSEPROPERTY_URL</code>
59 /// property for the response.
61 /// @return An <code>is_string Var</code> containing the response property
62 /// value if successful, <code>is_undefined Var</code> if an input parameter
65 return GetProperty(PP_URLRESPONSEPROPERTY_URL
);
68 /// This function gets the <code>PP_URLRESPONSEPROPERTY_REDIRECTURL</code>
69 /// property for the response.
71 /// @return An <code>is_string Var</code> containing the response property
72 /// value if successful, <code>is_undefined Var</code> if an input parameter
74 Var
GetRedirectURL() const {
75 return GetProperty(PP_URLRESPONSEPROPERTY_REDIRECTURL
);
78 /// This function gets the <code>PP_URLRESPONSEPROPERTY_REDIRECTMETHOD</code>
79 /// property for the response.
81 /// @return An <code>is_string Var</code> containing the response property
82 /// value if successful, <code>is_undefined Var</code> if an input parameter
84 Var
GetRedirectMethod() const {
85 return GetProperty(PP_URLRESPONSEPROPERTY_REDIRECTMETHOD
);
88 /// This function gets the <code>PP_URLRESPONSEPROPERTY_STATUSCODE</code>
89 /// property for the response.
91 /// @return A int32_t containing the response property value if successful,
92 /// <code>is_undefined Var</code> if an input parameter is invalid.
93 int32_t GetStatusCode() const {
94 return GetProperty(PP_URLRESPONSEPROPERTY_STATUSCODE
).AsInt();
97 /// This function gets the <code>PP_URLRESPONSEPROPERTY_STATUSLINE</code>
98 /// property for the response.
100 /// @return An <code>is_string Var</code> containing the response property
101 /// value if successful, <code>is_undefined Var</code> if an input parameter
103 Var
GetStatusLine() const {
104 return GetProperty(PP_URLRESPONSEPROPERTY_STATUSLINE
);
107 /// This function gets the <code>PP_URLRESPONSEPROPERTY_HEADERS</code>
108 /// property for the response.
110 /// @return An <code>is_string Var</code> containing the response property
111 /// value if successful, <code>is_undefined Var</code> if an input parameter
113 Var
GetHeaders() const {
114 return GetProperty(PP_URLRESPONSEPROPERTY_HEADERS
);
120 #endif // PPAPI_CPP_URL_RESPONSE_INFO_H_