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 "base/bind.h" |
8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
9 #include "ppapi/proxy/dispatch_reply_message.h" | 9 #include "ppapi/proxy/dispatch_reply_message.h" |
10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
11 #include "ppapi/shared_impl/var.h" | 11 #include "ppapi/shared_impl/var.h" |
12 | 12 |
13 namespace ppapi { | 13 namespace ppapi { |
14 namespace proxy { | 14 namespace proxy { |
15 | 15 |
16 FlashDeviceIDResource::FlashDeviceIDResource(Connection connection, | 16 FlashDeviceIDResource::FlashDeviceIDResource(Connection connection, |
17 PP_Instance instance) | 17 PP_Instance instance) |
18 : PluginResource(connection, instance), | 18 : PluginResource(connection, instance), |
19 dest_(NULL) { | 19 dest_(NULL) { |
20 SendCreateToBrowser(PpapiHostMsg_FlashDeviceID_Create()); | 20 SendCreate(BROWSER, PpapiHostMsg_FlashDeviceID_Create()); |
21 } | 21 } |
22 | 22 |
23 FlashDeviceIDResource::~FlashDeviceIDResource() { | 23 FlashDeviceIDResource::~FlashDeviceIDResource() { |
24 } | 24 } |
25 | 25 |
26 thunk::PPB_Flash_DeviceID_API* | 26 thunk::PPB_Flash_DeviceID_API* |
27 FlashDeviceIDResource::AsPPB_Flash_DeviceID_API() { | 27 FlashDeviceIDResource::AsPPB_Flash_DeviceID_API() { |
28 return this; | 28 return this; |
29 } | 29 } |
30 | 30 |
31 int32_t FlashDeviceIDResource::GetDeviceID( | 31 int32_t FlashDeviceIDResource::GetDeviceID( |
32 PP_Var* id, | 32 PP_Var* id, |
33 scoped_refptr<TrackedCallback> callback) { | 33 scoped_refptr<TrackedCallback> callback) { |
34 if (TrackedCallback::IsPending(callback_)) | 34 if (TrackedCallback::IsPending(callback_)) |
35 return PP_ERROR_INPROGRESS; | 35 return PP_ERROR_INPROGRESS; |
36 if (!id) | 36 if (!id) |
37 return PP_ERROR_BADARGUMENT; | 37 return PP_ERROR_BADARGUMENT; |
38 | 38 |
39 dest_ = id; | 39 dest_ = id; |
40 callback_ = callback; | 40 callback_ = callback; |
41 | 41 |
42 CallBrowser<PpapiPluginMsg_FlashDeviceID_GetDeviceIDReply>( | 42 Call<PpapiPluginMsg_FlashDeviceID_GetDeviceIDReply>( |
| 43 BROWSER, |
43 PpapiHostMsg_FlashDeviceID_GetDeviceID(), | 44 PpapiHostMsg_FlashDeviceID_GetDeviceID(), |
44 base::Bind(&FlashDeviceIDResource::OnPluginMsgGetDeviceIDReply, this)); | 45 base::Bind(&FlashDeviceIDResource::OnPluginMsgGetDeviceIDReply, this)); |
45 return PP_OK_COMPLETIONPENDING; | 46 return PP_OK_COMPLETIONPENDING; |
46 } | 47 } |
47 | 48 |
48 void FlashDeviceIDResource::OnPluginMsgGetDeviceIDReply( | 49 void FlashDeviceIDResource::OnPluginMsgGetDeviceIDReply( |
49 const ResourceMessageReplyParams& params, | 50 const ResourceMessageReplyParams& params, |
50 const std::string& id) { | 51 const std::string& id) { |
51 if (params.result() == PP_OK) | 52 if (params.result() == PP_OK) |
52 *dest_ = StringVar::StringToPPVar(id); | 53 *dest_ = StringVar::StringToPPVar(id); |
53 else | 54 else |
54 *dest_ = PP_MakeUndefined(); | 55 *dest_ = PP_MakeUndefined(); |
55 dest_ = NULL; | 56 dest_ = NULL; |
56 TrackedCallback::ClearAndRun(&callback_, params.result()); | 57 TrackedCallback::ClearAndRun(&callback_, params.result()); |
57 } | 58 } |
58 | 59 |
59 } // namespace proxy | 60 } // namespace proxy |
60 } // namespace ppapi | 61 } // namespace ppapi |
OLD | NEW |