Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: ppapi/proxy/flash_device_id_resource.cc

Issue 10909138: Convert the async device ID getter to a chrome resource host (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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/proxy/flash_device_id_resource.h"
6
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/proxy/dispatch_reply_message.h"
9 #include "ppapi/proxy/ppapi_messages.h"
10 #include "ppapi/shared_impl/var.h"
11
12 namespace ppapi {
13 namespace proxy {
14
15 FlashDeviceIDResource::FlashDeviceIDResource(Connection connection,
16 PP_Instance instance)
17 : PluginResource(connection, instance),
18 dest_(NULL) {
19 SendCreateToBrowser(PpapiHostMsg_FlashDeviceID_Create());
20 }
21
22 FlashDeviceIDResource::~FlashDeviceIDResource() {
23 }
24
25 thunk::PPB_Flash_DeviceID_API*
26 FlashDeviceIDResource::AsPPB_Flash_DeviceID_API() {
27 return this;
28 }
29
30 int32_t FlashDeviceIDResource::GetDeviceID(
31 PP_Var* id,
32 scoped_refptr<TrackedCallback> callback) {
33 if (TrackedCallback::IsPending(callback_))
34 return PP_ERROR_INPROGRESS;
35 if (!id)
36 return PP_ERROR_BADARGUMENT;
37
38 dest_ = id;
39 callback_ = callback;
40
41 CallBrowser(PpapiHostMsg_FlashDeviceID_GetDeviceID());
42 return PP_OK_COMPLETIONPENDING;
43 }
44
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(
56 const ResourceMessageReplyParams& params,
57 const std::string& id) {
58 if (params.result() == PP_OK)
59 *dest_ = StringVar::StringToPPVar(id);
60 else
61 *dest_ = PP_MakeUndefined();
62 dest_ = NULL;
63 TrackedCallback::ClearAndRun(&callback_, params.result());
64 }
65
66 } // namespace proxy
67 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698