Do not assume that the orientation is PORTRAIT by default.
[chromium-blink-merge.git] / ppapi / cpp / url_response_info.h
blobf9e60cfb828aae2fc9b6f34c1927eeefee03572a
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"
12 /// @file
13 /// This file defines the API for examining URL responses.
14 namespace pp {
16 class FileRef;
18 /// URLResponseInfo provides an API for examining URL responses.
19 class URLResponseInfo : public Resource {
20 public:
21 /// Default constructor. This constructor creates an <code>is_null</code>
22 /// resource.
23 URLResponseInfo() {}
25 /// A constructor used when you have received a <code>PP_Resource</code> as a
26 /// return value that has already been reference counted.
27 ///
28 /// @param[in] resource A <code>PP_Resource</code> corresponding to a
29 /// resource.
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.
36 ///
37 /// @param[in] property A <code>PP_URLResponseProperty</code> identifying the
38 /// type of property in the response.
39 ///
40 /// @return A <code>Var</code> containing the response property value if
41 /// successful, <code>is_undefined Var</code> if an input parameter is
42 /// invalid.
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.
51 ///
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.
60 ///
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
63 /// is invalid.
64 Var GetURL() const {
65 return GetProperty(PP_URLRESPONSEPROPERTY_URL);
68 /// This function gets the <code>PP_URLRESPONSEPROPERTY_REDIRECTURL</code>
69 /// property for the response.
70 ///
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
73 /// is invalid.
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.
80 ///
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
83 /// is invalid.
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.
90 ///
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.
99 ///
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
102 /// is invalid.
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
112 /// is invalid.
113 Var GetHeaders() const {
114 return GetProperty(PP_URLRESPONSEPROPERTY_HEADERS);
118 } // namespace pp
120 #endif // PPAPI_CPP_URL_RESPONSE_INFO_H_