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 "chrome/browser/renderer_host/pepper/pepper_flash_device_id_host.h" | 5 #include "chrome/browser/renderer_host/pepper/pepper_flash_drm_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "content/public/browser/browser_ppapi_host.h" | 10 #include "content/public/browser/browser_ppapi_host.h" |
11 #include "ppapi/c/pp_errors.h" | 11 #include "ppapi/c/pp_errors.h" |
12 #include "ppapi/host/dispatch_host_message.h" | 12 #include "ppapi/host/dispatch_host_message.h" |
13 #include "ppapi/host/host_message_context.h" | 13 #include "ppapi/host/host_message_context.h" |
14 #include "ppapi/host/ppapi_host.h" | 14 #include "ppapi/host/ppapi_host.h" |
15 #include "ppapi/proxy/ppapi_messages.h" | 15 #include "ppapi/proxy/ppapi_messages.h" |
16 | 16 |
17 using content::BrowserPpapiHost; | 17 using content::BrowserPpapiHost; |
18 | 18 |
19 namespace chrome { | 19 namespace chrome { |
20 | 20 |
21 PepperFlashDeviceIDHost::PepperFlashDeviceIDHost(BrowserPpapiHost* host, | 21 PepperFlashDRMHost::PepperFlashDRMHost(BrowserPpapiHost* host, |
22 PP_Instance instance, | 22 PP_Instance instance, |
23 PP_Resource resource) | 23 PP_Resource resource) |
24 : ppapi::host::ResourceHost(host->GetPpapiHost(), instance, resource), | 24 : ppapi::host::ResourceHost(host->GetPpapiHost(), instance, resource), |
25 weak_factory_(this){ | 25 weak_factory_(this){ |
26 int render_process_id, unused; | 26 int render_process_id, unused; |
27 host->GetRenderViewIDsForInstance(instance, &render_process_id, &unused); | 27 host->GetRenderViewIDsForInstance(instance, &render_process_id, &unused); |
28 fetcher_ = new DeviceIDFetcher(render_process_id); | 28 fetcher_ = new DeviceIDFetcher(render_process_id); |
29 } | 29 } |
30 | 30 |
31 PepperFlashDeviceIDHost::~PepperFlashDeviceIDHost() { | 31 PepperFlashDRMHost::~PepperFlashDRMHost() { |
32 } | 32 } |
33 | 33 |
34 int32_t PepperFlashDeviceIDHost::OnResourceMessageReceived( | 34 int32_t PepperFlashDRMHost::OnResourceMessageReceived( |
35 const IPC::Message& msg, | 35 const IPC::Message& msg, |
36 ppapi::host::HostMessageContext* context) { | 36 ppapi::host::HostMessageContext* context) { |
37 IPC_BEGIN_MESSAGE_MAP(PepperFlashDeviceIDHost, msg) | 37 IPC_BEGIN_MESSAGE_MAP(PepperFlashDRMHost, msg) |
38 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FlashDeviceID_GetDeviceID, | 38 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FlashDRM_GetDeviceID, |
39 OnHostMsgGetDeviceID) | 39 OnHostMsgGetDeviceID) |
40 IPC_END_MESSAGE_MAP() | 40 IPC_END_MESSAGE_MAP() |
41 return PP_ERROR_FAILED; | 41 return PP_ERROR_FAILED; |
42 } | 42 } |
43 | 43 |
44 int32_t PepperFlashDeviceIDHost::OnHostMsgGetDeviceID( | 44 int32_t PepperFlashDRMHost::OnHostMsgGetDeviceID( |
45 const ppapi::host::HostMessageContext* context) { | 45 ppapi::host::HostMessageContext* context) { |
46 if (!fetcher_->Start(base::Bind(&PepperFlashDeviceIDHost::GotDeviceID, | 46 if (!fetcher_->Start(base::Bind(&PepperFlashDRMHost::GotDeviceID, |
47 weak_factory_.GetWeakPtr(), | 47 weak_factory_.GetWeakPtr(), |
48 context->MakeReplyMessageContext()))) { | 48 context->MakeReplyMessageContext()))) { |
49 return PP_ERROR_INPROGRESS; | 49 return PP_ERROR_INPROGRESS; |
50 } | 50 } |
51 return PP_OK_COMPLETIONPENDING; | 51 return PP_OK_COMPLETIONPENDING; |
52 } | 52 } |
53 | 53 |
54 void PepperFlashDeviceIDHost::GotDeviceID( | 54 void PepperFlashDRMHost::GotDeviceID( |
55 ppapi::host::ReplyMessageContext reply_context, | 55 ppapi::host::ReplyMessageContext reply_context, |
56 const std::string& id) { | 56 const std::string& id) { |
57 reply_context.params.set_result( | 57 reply_context.params.set_result( |
58 id.empty() ? PP_ERROR_FAILED : PP_OK); | 58 id.empty() ? PP_ERROR_FAILED : PP_OK); |
59 host()->SendReply(reply_context, | 59 host()->SendReply(reply_context, |
60 PpapiPluginMsg_FlashDeviceID_GetDeviceIDReply(id)); | 60 PpapiPluginMsg_FlashDRM_GetDeviceIDReply(id)); |
61 } | 61 } |
62 | 62 |
63 } // namespace chrome | 63 } // namespace chrome |
OLD | NEW |