OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014 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/proxy/mojo_resource.h" |
| 6 |
| 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/proxy/ppapi_messages.h" |
| 9 |
| 10 namespace ppapi { |
| 11 namespace proxy { |
| 12 |
| 13 MojoResource::MojoResource(Connection connection, PP_Instance instance) |
| 14 : PluginResource(connection, instance) { |
| 15 SendCreate(BROWSER, PpapiHostMsg_Mojo_Create()); |
| 16 } |
| 17 |
| 18 MojoResource::~MojoResource() { |
| 19 } |
| 20 |
| 21 thunk::PPB_Mojo_API* MojoResource::AsPPB_Mojo_API() { |
| 22 return this; |
| 23 } |
| 24 |
| 25 int32_t MojoResource::GetHandle(PP_Instance instance, |
| 26 uint32_t* out_mojo_handle, |
| 27 scoped_refptr<TrackedCallback> callback) { |
| 28 Call<PpapiPluginMsg_Mojo_GetHandleReply>( |
| 29 BROWSER, |
| 30 PpapiHostMsg_Mojo_GetHandle(), |
| 31 base::Bind(&MojoResource::GetHandleComplete, |
| 32 this, out_mojo_handle, callback)); |
| 33 return PP_OK_COMPLETIONPENDING; |
| 34 } |
| 35 |
| 36 void MojoResource::GetHandleComplete(uint32_t* out_mojo_handle, |
| 37 scoped_refptr<TrackedCallback> callback, |
| 38 const ResourceMessageReplyParams& params) { |
| 39 IPC::PlatformFileForTransit transit_file; |
| 40 if (!params.TakeFileHandleAtIndex(0, &transit_file)) { |
| 41 callback->Run(PP_ERROR_FAILED); |
| 42 return; |
| 43 } |
| 44 *out_mojo_handle = transit_file.fd; |
| 45 callback->Run(PP_OK); |
| 46 } |
| 47 |
| 48 } // namespace proxy |
| 49 } // namespace ppapi |
OLD | NEW |