Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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_Dev; | 16 class FileRef_Dev; |
| 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 is_null resource. |
| 19 URLResponseInfo() {} | 22 URLResponseInfo() {} |
| 20 | 23 |
| 21 // This constructor is used when we've gotten a PP_Resource as a return value | 24 /// Not sure what to put here |
|
polina
2011/08/01 10:35:51
Copy from image_data.h
jond
2011/08/01 21:03:09
Done.
| |
| 22 // that has already been addref'ed for us. | |
| 23 struct PassRef {}; | 25 struct PassRef {}; |
| 26 | |
| 27 /// A constructor used when a PP_Resource is provided as a return value | |
|
polina
2011/08/01 10:35:51
not really
Copy from image_data.h
jond
2011/08/01 21:03:09
Done.
| |
| 28 /// whose reference count has already been incremented. | |
| 29 /// | |
| 30 /// @param[in] resource A PP_Resource. | |
| 24 URLResponseInfo(PassRef, PP_Resource resource); | 31 URLResponseInfo(PassRef, PP_Resource resource); |
| 25 | 32 |
| 33 /// A constructor for copying an URLResponseInfo. | |
|
polina
2011/08/01 10:35:51
The copy constructor
jond
2011/08/01 21:03:09
Done.
| |
| 26 URLResponseInfo(const URLResponseInfo& other); | 34 URLResponseInfo(const URLResponseInfo& other); |
| 27 | 35 |
| 28 // PPB_URLResponseInfo methods: | 36 // PPB_URLResponseInfo methods: |
|
polina
2011/08/01 10:35:51
Did you leave this here by accident?
jond
2011/08/01 21:03:09
Done.
| |
| 37 | |
| 38 /// This function gets a response property. | |
| 39 /// | |
| 40 /// @param[in] property A PP_URLResponseProperty identifying the type of | |
| 41 /// property in the response. | |
| 42 /// @return A PP_Var containing the response property value if successful, | |
|
polina
2011/08/01 10:35:51
Var, not PP_Var
(please apply to other functions a
jond
2011/08/01 21:03:09
Done.
| |
| 43 /// PP_VARTYPE_VOID if an input parameter is invalid. | |
|
polina
2011/08/01 10:35:51
is_undefined Var, not PP_VARTYPE_VOID
(please appl
jond
2011/08/01 21:03:09
Done.
jond
2011/08/01 21:03:09
Done.
| |
| 29 Var GetProperty(PP_URLResponseProperty property) const; | 44 Var GetProperty(PP_URLResponseProperty property) const; |
| 45 | |
| 46 /// This function returns a FileRef | |
|
polina
2011/08/01 10:35:51
You seem to be using <code> in some places, but no
jond
2011/08/01 21:03:09
Done.
| |
| 47 /// pointing to the file containing the response body. This | |
| 48 /// is only valid if PP_URLREQUESTPROPERTY_STREAMTOFILE was set on the | |
| 49 /// URLRequestInfo used to produce this response. This file remains valid | |
| 50 /// until the URLLoader associated with this URLResponseInfo is closed or | |
| 51 /// destroyed. | |
| 52 /// | |
| 53 /// @return A PP_Resource corresponding to a FileRef if successful, 0 if | |
|
polina
2011/08/01 10:35:51
FileRef_Dev, not PP_Resource
polina
2011/08/01 10:35:51
is_null object, not 0
jond
2011/08/01 21:03:09
Done.
jond
2011/08/01 21:03:09
Done.
jond
2011/08/01 21:03:09
Done.
| |
| 54 /// PP_URLREQUESTPROPERTY_STREAMTOFILE was not requested or if the URLLoader | |
| 55 /// has not been opened yet. | |
| 30 FileRef_Dev GetBodyAsFileRef() const; | 56 FileRef_Dev GetBodyAsFileRef() const; |
| 31 | 57 |
| 32 // Convenient helpers for getting properties: | 58 /// This function gets the PP_URLRESPONSEPROPERTY_URL (corresponding to a |
|
polina
2011/08/01 10:35:51
instead of putting "corresponding to a type..." in
jond
2011/08/01 21:03:09
Done.
| |
| 59 /// string of type PP_VARTYPE_STRING) property for the response. | |
| 60 /// | |
| 61 /// @return A PP_Var containing the response property value if successful, | |
| 62 /// PP_VARTYPE_VOID if an input parameter is invalid. | |
| 33 Var GetURL() const { | 63 Var GetURL() const { |
| 34 return GetProperty(PP_URLRESPONSEPROPERTY_URL); | 64 return GetProperty(PP_URLRESPONSEPROPERTY_URL); |
| 35 } | 65 } |
| 66 | |
| 67 /// This function gets the PP_URLRESPONSEPROPERTY_REDIRECTURL (corresponding | |
| 68 /// to a string of type PP_VARTYPE_STRING) property for the response. | |
| 69 /// | |
| 70 /// @return A PP_Var containing the response property value if successful, | |
| 71 /// PP_VARTYPE_VOID if an input parameter is invalid. | |
| 36 Var GetRedirectURL() const { | 72 Var GetRedirectURL() const { |
| 37 return GetProperty(PP_URLRESPONSEPROPERTY_REDIRECTURL); | 73 return GetProperty(PP_URLRESPONSEPROPERTY_REDIRECTURL); |
| 38 } | 74 } |
| 75 | |
| 76 /// This function gets the PP_URLRESPONSEPROPERTY_REDIRECTMETHOD | |
| 77 /// (corresponding to a string of type PP_VARTYPE_STRING) property for the | |
| 78 /// response. | |
| 79 /// | |
| 80 /// @return A PP_Var containing the response property value if successful, | |
| 81 /// PP_VARTYPE_VOID if an input parameter is invalid. | |
| 39 Var GetRedirectMethod() const { | 82 Var GetRedirectMethod() const { |
| 40 return GetProperty(PP_URLRESPONSEPROPERTY_REDIRECTMETHOD); | 83 return GetProperty(PP_URLRESPONSEPROPERTY_REDIRECTMETHOD); |
| 41 } | 84 } |
| 85 | |
| 86 /// This function gets the PP_URLRESPONSEPROPERTY_STATUSCODE (corresponding | |
| 87 /// to an int32 of type PP_VARTYPE_INT32) property for the response. | |
| 88 /// | |
| 89 /// @return A int32_t containing the response property value if successful, | |
| 90 /// PP_VARTYPE_VOID if an input parameter is invalid. | |
| 42 int32_t GetStatusCode() const { | 91 int32_t GetStatusCode() const { |
| 43 return GetProperty(PP_URLRESPONSEPROPERTY_STATUSCODE).AsInt(); | 92 return GetProperty(PP_URLRESPONSEPROPERTY_STATUSCODE).AsInt(); |
| 44 } | 93 } |
| 94 | |
| 95 /// This function gets the PP_URLRESPONSEPROPERTY_STATUSLINE (corresponding | |
| 96 /// to a string of type PP_VARTYPE_STRING) property for the response. | |
| 97 /// | |
| 98 /// @return A PP_Var containing the response property value if successful, | |
| 99 /// PP_VARTYPE_VOID if an input parameter is invalid. | |
| 45 Var GetStatusLine() const { | 100 Var GetStatusLine() const { |
| 46 return GetProperty(PP_URLRESPONSEPROPERTY_STATUSLINE); | 101 return GetProperty(PP_URLRESPONSEPROPERTY_STATUSLINE); |
| 47 } | 102 } |
| 103 | |
| 104 /// This function gets the PP_URLRESPONSEPROPERTY_HEADERS (corresponding to a | |
| 105 /// string of type PP_VARTYPE_STRING) property for the response. | |
| 106 /// | |
| 107 /// @return A PP_Var containing the response property value if successful, | |
| 108 /// PP_VARTYPE_VOID if an input parameter is invalid. | |
| 48 Var GetHeaders() const { | 109 Var GetHeaders() const { |
| 49 return GetProperty(PP_URLRESPONSEPROPERTY_HEADERS); | 110 return GetProperty(PP_URLRESPONSEPROPERTY_HEADERS); |
| 50 } | 111 } |
| 51 }; | 112 }; |
| 52 | 113 |
| 53 } // namespace pp | 114 } // namespace pp |
| 54 | 115 |
| 55 #endif // PPAPI_CPP_URL_RESPONSE_INFO_H_ | 116 #endif // PPAPI_CPP_URL_RESPONSE_INFO_H_ |
| OLD | NEW |