OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PPAPI_CPP_URL_RESPONSE_INFO_H_ | 5 #ifndef PPAPI_CPP_URL_RESPONSE_INFO_H_ |
6 #define PPAPI_CPP_URL_RESPONSE_INFO_H_ | 6 #define PPAPI_CPP_URL_RESPONSE_INFO_H_ |
7 | 7 |
8 #include "ppapi/c/ppb_url_response_info.h" | 8 #include "ppapi/c/ppb_url_response_info.h" |
9 #include "ppapi/cpp/resource.h" | 9 #include "ppapi/cpp/resource.h" |
10 #include "ppapi/cpp/var.h" | 10 #include "ppapi/cpp/var.h" |
11 | 11 |
12 /// @file | |
13 /// This file defines the API for examining URL responses. | |
12 namespace pp { | 14 namespace pp { |
13 | 15 |
14 class FileRef; | 16 class FileRef; |
15 | 17 |
18 /// URLResponseInfo provides an API for examaning URL responses. | |
16 class URLResponseInfo : public Resource { | 19 class URLResponseInfo : public Resource { |
17 public: | 20 public: |
18 // Creates an is_null() URLResponseInfo object. | 21 /// Default constructor. This constructor creates an <code>is_null</code> |
polina
2011/08/03 00:28:33
same comment about consistency as in the other fil
jond
2011/08/05 17:07:47
Right. I will address these all at the same time a
| |
22 /// resource. | |
19 URLResponseInfo() {} | 23 URLResponseInfo() {} |
20 | 24 |
21 // This constructor is used when we've gotten a PP_Resource as a return value | 25 /// A special structure used by the constructor that does not increment the |
22 // that has already been addref'ed for us. | 26 /// reference count of the underlying resource. |
23 struct PassRef {}; | 27 struct PassRef {}; |
28 | |
29 /// A constructor used when you have received a <code>PP_Resource</code> as a | |
30 /// return value that has already been reference counted. | |
31 /// | |
32 /// @param[in] resource A <code>PP_Resource</code>. | |
24 URLResponseInfo(PassRef, PP_Resource resource); | 33 URLResponseInfo(PassRef, PP_Resource resource); |
25 | 34 |
35 /// The copy constructor. | |
polina
2011/08/03 00:28:33
for <code>URLResponseInfo</code>?
jond
2011/08/05 17:07:47
Done.
jond
2011/08/05 17:07:47
Done.
| |
26 URLResponseInfo(const URLResponseInfo& other); | 36 URLResponseInfo(const URLResponseInfo& other); |
27 | 37 |
28 // PPB_URLResponseInfo methods: | 38 /// This function gets a response property. |
39 /// | |
40 /// @param[in] property A <code>PP_URLResponseProperty</code> identifying the | |
41 /// type of property in the response. | |
42 /// @return A <code>Var</code> containing the response property value if | |
43 /// successful, <code>is_undefined Var</code> if an input parameter is | |
44 /// invalid. | |
29 Var GetProperty(PP_URLResponseProperty property) const; | 45 Var GetProperty(PP_URLResponseProperty property) const; |
30 FileRef GetBodyAsFileRef() const; | |
31 | 46 |
32 // Convenient helpers for getting properties: | 47 /// This function returns a <code>FileRef</code> |
48 /// pointing to the file containing the response body. This | |
49 /// is only valid if <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> was set | |
50 /// on the <code>URLRequestInfo</code> used to produce this response. This | |
51 /// file remains valid until the <code>URLLoader</code> associated with this | |
52 /// <code>URLResponseInfo is closed or destroyed. | |
53 /// | |
54 /// @return A <code>FileRef_Dev</code> corresponding to a | |
polina
2011/08/03 00:28:33
no _Dev here and in the function signature?
(sync
polina
2011/08/04 22:01:04
Still erroneous _Dev in your comment.
jond
2011/08/05 17:07:47
Done.
| |
55 /// <code>FileRef</code> if successful, an <code>is_null</code> object if | |
56 /// <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> was not requested or if | |
57 /// the <code>URLLoader</code> has not been opened yet. | |
58 FileRef_Dev GetBodyAsFileRef() const; | |
59 | |
60 /// This function gets the <code>PP_URLRESPONSEPROPERTY_URL</code> | |
61 /// property for the response. | |
62 /// | |
63 /// @return An <code>is_string Var</code> containing the response property | |
64 /// value if successful, <code>is_undefined Var</code> if an input parameter | |
65 /// is invalid. | |
33 Var GetURL() const { | 66 Var GetURL() const { |
34 return GetProperty(PP_URLRESPONSEPROPERTY_URL); | 67 return GetProperty(PP_URLRESPONSEPROPERTY_URL); |
35 } | 68 } |
69 | |
70 /// This function gets the <code>PP_URLRESPONSEPROPERTY_REDIRECTURL</code> | |
71 /// property for the response. | |
72 /// | |
73 /// @return An <code>is_string Var</code> containing the response property | |
74 /// value if successful, <code>is_undefined Var</code> if an input parameter | |
75 /// is invalid. | |
36 Var GetRedirectURL() const { | 76 Var GetRedirectURL() const { |
37 return GetProperty(PP_URLRESPONSEPROPERTY_REDIRECTURL); | 77 return GetProperty(PP_URLRESPONSEPROPERTY_REDIRECTURL); |
38 } | 78 } |
79 | |
80 /// This function gets the <code>PP_URLRESPONSEPROPERTY_REDIRECTMETHOD</code> | |
81 /// property for the response. | |
82 /// | |
83 /// @return An <code>is_string Var</code> containing the response property | |
84 /// value if successful, <code>is_undefined Var</code> if an input parameter | |
85 /// is invalid. | |
39 Var GetRedirectMethod() const { | 86 Var GetRedirectMethod() const { |
40 return GetProperty(PP_URLRESPONSEPROPERTY_REDIRECTMETHOD); | 87 return GetProperty(PP_URLRESPONSEPROPERTY_REDIRECTMETHOD); |
41 } | 88 } |
89 | |
90 /// This function gets the <code>PP_URLRESPONSEPROPERTY_STATUSCODE</code> | |
91 /// property for the response. | |
92 /// | |
93 /// @return A int32_t containing the response property value if successful, | |
94 /// <code>is_undefined Var</code> if an input parameter is invalid. | |
42 int32_t GetStatusCode() const { | 95 int32_t GetStatusCode() const { |
43 return GetProperty(PP_URLRESPONSEPROPERTY_STATUSCODE).AsInt(); | 96 return GetProperty(PP_URLRESPONSEPROPERTY_STATUSCODE).AsInt(); |
44 } | 97 } |
98 | |
99 /// This function gets the <code>PP_URLRESPONSEPROPERTY_STATUSLINE</code> | |
100 /// property for the response. | |
101 /// | |
102 /// @return An <code>is_string Var</code> containing the response property | |
103 /// value if successful, <code>is_undefined Var</code> if an input parameter | |
104 /// is invalid. | |
45 Var GetStatusLine() const { | 105 Var GetStatusLine() const { |
46 return GetProperty(PP_URLRESPONSEPROPERTY_STATUSLINE); | 106 return GetProperty(PP_URLRESPONSEPROPERTY_STATUSLINE); |
47 } | 107 } |
108 | |
109 /// This function gets the <code>PP_URLRESPONSEPROPERTY_HEADERS</code> | |
110 /// property for the response. | |
111 /// | |
112 /// @return An <code>is_string Var</code> containing the response property | |
113 /// value if successful, <code>is_undefined Var</code> if an input parameter | |
114 /// is invalid. | |
48 Var GetHeaders() const { | 115 Var GetHeaders() const { |
49 return GetProperty(PP_URLRESPONSEPROPERTY_HEADERS); | 116 return GetProperty(PP_URLRESPONSEPROPERTY_HEADERS); |
50 } | 117 } |
51 }; | 118 }; |
52 | 119 |
53 } // namespace pp | 120 } // namespace pp |
54 | 121 |
55 #endif // PPAPI_CPP_URL_RESPONSE_INFO_H_ | 122 #endif // PPAPI_CPP_URL_RESPONSE_INFO_H_ |
OLD | NEW |