| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Native Client 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 | |
| 5 #include "native_client/tests/fake_browser_ppapi/fake_url_response_info.h" | |
| 6 | |
| 7 #include <stdio.h> | |
| 8 | |
| 9 #include "native_client/src/include/nacl_macros.h" | |
| 10 #include "native_client/src/include/portability.h" | |
| 11 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_var_deprecated.h" | |
| 12 | |
| 13 #include "native_client/tests/fake_browser_ppapi/fake_file_ref.h" | |
| 14 #include "native_client/tests/fake_browser_ppapi/fake_resource.h" | |
| 15 #include "native_client/tests/fake_browser_ppapi/utility.h" | |
| 16 | |
| 17 #include "ppapi/c/pp_completion_callback.h" | |
| 18 #include "ppapi/c/pp_resource.h" | |
| 19 | |
| 20 using fake_browser_ppapi::DebugPrintf; | |
| 21 using ppapi_proxy::PluginVarDeprecated; | |
| 22 | |
| 23 namespace fake_browser_ppapi { | |
| 24 | |
| 25 namespace { | |
| 26 | |
| 27 PP_Bool IsURLResponseInfo(PP_Resource resource_id) { | |
| 28 DebugPrintf("URLRequestInfo::IsURLResponseInfo: resource_id=%"NACL_PRId32"\n", | |
| 29 resource_id); | |
| 30 NACL_UNIMPLEMENTED(); | |
| 31 return PP_FALSE; | |
| 32 } | |
| 33 | |
| 34 PP_Var GetProperty(PP_Resource response_id, | |
| 35 PP_URLResponseProperty property) { | |
| 36 DebugPrintf("URLRequestInfo::GetProperty: response_id=%"NACL_PRId32"\n", | |
| 37 response_id); | |
| 38 URLResponseInfo* response = GetResource(response_id)->AsURLResponseInfo(); | |
| 39 if (response == NULL) | |
| 40 return PP_MakeUndefined(); | |
| 41 | |
| 42 switch (property) { | |
| 43 case PP_URLRESPONSEPROPERTY_URL: | |
| 44 return PluginVarDeprecated::StringToPPVar(response->module_id(), | |
| 45 response->url()); | |
| 46 case PP_URLRESPONSEPROPERTY_STATUSCODE: | |
| 47 return PP_MakeInt32(response->status_code()); | |
| 48 case PP_URLRESPONSEPROPERTY_HEADERS: | |
| 49 case PP_URLRESPONSEPROPERTY_REDIRECTURL: | |
| 50 case PP_URLRESPONSEPROPERTY_REDIRECTMETHOD: | |
| 51 case PP_URLRESPONSEPROPERTY_STATUSLINE: | |
| 52 NACL_UNIMPLEMENTED(); | |
| 53 } | |
| 54 return PP_MakeUndefined(); | |
| 55 } | |
| 56 | |
| 57 PP_Resource GetBodyAsFileRef(PP_Resource response_id) { | |
| 58 DebugPrintf("URLRequestInfo::GetBodyAsFileRef: response_id=%"NACL_PRId32"\n", | |
| 59 response_id); | |
| 60 URLResponseInfo* response = GetResource(response_id)->AsURLResponseInfo(); | |
| 61 if (response == NULL) | |
| 62 return Resource::Invalid()->resource_id(); | |
| 63 FileRef* file_ref = response->body_as_file_ref(); | |
| 64 CHECK(file_ref != NULL); | |
| 65 return file_ref->resource_id(); | |
| 66 } | |
| 67 | |
| 68 } // namespace | |
| 69 | |
| 70 | |
| 71 const PPB_URLResponseInfo* URLResponseInfo::GetInterface() { | |
| 72 static const PPB_URLResponseInfo url_response_info_interface = { | |
| 73 IsURLResponseInfo, | |
| 74 GetProperty, | |
| 75 GetBodyAsFileRef | |
| 76 }; | |
| 77 return &url_response_info_interface; | |
| 78 } | |
| 79 | |
| 80 } // namespace fake_browser_ppapi | |
| OLD | NEW |