| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "ppapi/proxy/flash_device_id_resource.h" | 5 #include "ppapi/proxy/flash_device_id_resource.h" |
| 6 | 6 |
| 7 #include "base/bind.h" |
| 7 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/proxy/dispatch_reply_message.h" | 9 #include "ppapi/proxy/dispatch_reply_message.h" |
| 9 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
| 10 #include "ppapi/shared_impl/var.h" | 11 #include "ppapi/shared_impl/var.h" |
| 11 | 12 |
| 12 namespace ppapi { | 13 namespace ppapi { |
| 13 namespace proxy { | 14 namespace proxy { |
| 14 | 15 |
| 15 FlashDeviceIDResource::FlashDeviceIDResource(Connection connection, | 16 FlashDeviceIDResource::FlashDeviceIDResource(Connection connection, |
| 16 PP_Instance instance) | 17 PP_Instance instance) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 31 PP_Var* id, | 32 PP_Var* id, |
| 32 scoped_refptr<TrackedCallback> callback) { | 33 scoped_refptr<TrackedCallback> callback) { |
| 33 if (TrackedCallback::IsPending(callback_)) | 34 if (TrackedCallback::IsPending(callback_)) |
| 34 return PP_ERROR_INPROGRESS; | 35 return PP_ERROR_INPROGRESS; |
| 35 if (!id) | 36 if (!id) |
| 36 return PP_ERROR_BADARGUMENT; | 37 return PP_ERROR_BADARGUMENT; |
| 37 | 38 |
| 38 dest_ = id; | 39 dest_ = id; |
| 39 callback_ = callback; | 40 callback_ = callback; |
| 40 | 41 |
| 41 CallBrowser(PpapiHostMsg_FlashDeviceID_GetDeviceID()); | 42 CallBrowser<PpapiPluginMsg_FlashDeviceID_GetDeviceIDReply>( |
| 43 PpapiHostMsg_FlashDeviceID_GetDeviceID(), |
| 44 base::Bind(&FlashDeviceIDResource::OnPluginMsgGetDeviceIDReply, this)); |
| 42 return PP_OK_COMPLETIONPENDING; | 45 return PP_OK_COMPLETIONPENDING; |
| 43 } | 46 } |
| 44 | 47 |
| 45 void FlashDeviceIDResource::OnReplyReceived( | |
| 46 const ResourceMessageReplyParams& params, | |
| 47 const IPC::Message& msg) { | |
| 48 IPC_BEGIN_MESSAGE_MAP(FlashDeviceIDResource, msg) | |
| 49 PPAPI_DISPATCH_RESOURCE_REPLY( | |
| 50 PpapiPluginMsg_FlashDeviceID_GetDeviceIDReply, | |
| 51 OnPluginMsgGetDeviceIDReply) | |
| 52 IPC_END_MESSAGE_MAP() | |
| 53 } | |
| 54 | |
| 55 void FlashDeviceIDResource::OnPluginMsgGetDeviceIDReply( | 48 void FlashDeviceIDResource::OnPluginMsgGetDeviceIDReply( |
| 56 const ResourceMessageReplyParams& params, | 49 const ResourceMessageReplyParams& params, |
| 57 const std::string& id) { | 50 const std::string& id) { |
| 58 if (params.result() == PP_OK) | 51 if (params.result() == PP_OK) |
| 59 *dest_ = StringVar::StringToPPVar(id); | 52 *dest_ = StringVar::StringToPPVar(id); |
| 60 else | 53 else |
| 61 *dest_ = PP_MakeUndefined(); | 54 *dest_ = PP_MakeUndefined(); |
| 62 dest_ = NULL; | 55 dest_ = NULL; |
| 63 TrackedCallback::ClearAndRun(&callback_, params.result()); | 56 TrackedCallback::ClearAndRun(&callback_, params.result()); |
| 64 } | 57 } |
| 65 | 58 |
| 66 } // namespace proxy | 59 } // namespace proxy |
| 67 } // namespace ppapi | 60 } // namespace ppapi |
| OLD | NEW |