ppb_url_response_info_thunk.cc revision 5821806d5e7f356e8fa4b058a389a808ea183019
1// Copyright (c) 2012 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. 4 5#include "ppapi/thunk/thunk.h" 6#include "ppapi/thunk/enter.h" 7#include "ppapi/thunk/ppb_url_response_info_api.h" 8#include "ppapi/thunk/resource_creation_api.h" 9 10namespace ppapi { 11namespace thunk { 12 13namespace { 14 15PP_Bool IsURLResponseInfo(PP_Resource resource) { 16 EnterResource<PPB_URLResponseInfo_API> enter(resource, false); 17 return PP_FromBool(enter.succeeded()); 18} 19 20PP_Var GetProperty(PP_Resource response, PP_URLResponseProperty property) { 21 EnterResource<PPB_URLResponseInfo_API> enter(response, true); 22 if (!enter.succeeded()) 23 return PP_MakeUndefined(); 24 return enter.object()->GetProperty(property); 25} 26 27PP_Resource GetBodyAsFileRef(PP_Resource response) { 28 EnterResource<PPB_URLResponseInfo_API> enter(response, true); 29 if (!enter.succeeded()) 30 return 0; 31 return enter.object()->GetBodyAsFileRef(); 32} 33 34const PPB_URLResponseInfo g_ppb_url_response_info_thunk = { 35 &IsURLResponseInfo, 36 &GetProperty, 37 &GetBodyAsFileRef 38}; 39 40} // namespace 41 42const PPB_URLResponseInfo_1_0* GetPPB_URLResponseInfo_1_0_Thunk() { 43 return &g_ppb_url_response_info_thunk; 44} 45 46} // namespace thunk 47} // namespace ppapi 48