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

Side by Side Diff: chrome/renderer/pepper/pepper_flash_drm_renderer_host.cc

Issue 21966004: Pepper: Move FileRef to the "new" resource proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove code duplication Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
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/renderer/pepper/pepper_flash_drm_renderer_host.h" 5 #include "chrome/renderer/pepper/pepper_flash_drm_renderer_host.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "content/public/renderer/pepper_plugin_instance.h" 8 #include "content/public/renderer/pepper_plugin_instance.h"
9 #include "content/public/renderer/renderer_ppapi_host.h" 9 #include "content/public/renderer/renderer_ppapi_host.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
11 #include "ppapi/host/dispatch_host_message.h" 11 #include "ppapi/host/dispatch_host_message.h"
12 #include "ppapi/host/host_message_context.h" 12 #include "ppapi/host/host_message_context.h"
13 #include "ppapi/host/ppapi_host.h" 13 #include "ppapi/host/ppapi_host.h"
14 #include "ppapi/proxy/ppapi_messages.h" 14 #include "ppapi/proxy/ppapi_messages.h"
15 #include "ppapi/proxy/ppb_file_ref_proxy.h"
16 15
17 namespace chrome { 16 namespace chrome {
18 17
19 // TODO(raymes): This is duplicated from pepper_flash_drm_host.cc but once 18 // TODO(raymes): This is duplicated from pepper_flash_drm_host.cc but once
20 // FileRef is refactored to the browser, it won't need to be. 19 // FileRef is refactored to the browser, it won't need to be.
21 namespace { 20 namespace {
22 const base::FilePath::CharType kVoucherFilename[] = 21 const base::FilePath::CharType kVoucherFilename[] =
23 FILE_PATH_LITERAL("plugin.vch"); 22 FILE_PATH_LITERAL("plugin.vch");
24 } // namespace 23 } // namespace
25 24
26 PepperFlashDRMRendererHost::PepperFlashDRMRendererHost( 25 PepperFlashDRMRendererHost::PepperFlashDRMRendererHost(
27 content::RendererPpapiHost* host, 26 content::RendererPpapiHost* host,
28 PP_Instance instance, 27 PP_Instance instance,
29 PP_Resource resource) 28 PP_Resource resource)
30 : ResourceHost(host->GetPpapiHost(), instance, resource), 29 : ResourceHost(host->GetPpapiHost(), instance, resource),
31 renderer_ppapi_host_(host) { 30 renderer_ppapi_host_(host),
31 weak_factory_(this) {
32 } 32 }
33 33
34 PepperFlashDRMRendererHost::~PepperFlashDRMRendererHost() { 34 PepperFlashDRMRendererHost::~PepperFlashDRMRendererHost() {
35 } 35 }
36 36
37 int32_t PepperFlashDRMRendererHost::OnResourceMessageReceived( 37 int32_t PepperFlashDRMRendererHost::OnResourceMessageReceived(
38 const IPC::Message& msg, 38 const IPC::Message& msg,
39 ppapi::host::HostMessageContext* context) { 39 ppapi::host::HostMessageContext* context) {
40 IPC_BEGIN_MESSAGE_MAP(PepperFlashDRMRendererHost, msg) 40 IPC_BEGIN_MESSAGE_MAP(PepperFlashDRMRendererHost, msg)
41 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FlashDRM_GetVoucherFile, 41 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_FlashDRM_GetVoucherFile,
42 OnGetVoucherFile) 42 OnGetVoucherFile)
43 IPC_END_MESSAGE_MAP() 43 IPC_END_MESSAGE_MAP()
44 return PP_ERROR_FAILED; 44 return PP_ERROR_FAILED;
45 } 45 }
46 46
47 int32_t PepperFlashDRMRendererHost::OnGetVoucherFile( 47 int32_t PepperFlashDRMRendererHost::OnGetVoucherFile(
48 ppapi::host::HostMessageContext* context) { 48 ppapi::host::HostMessageContext* context) {
49 content::PepperPluginInstance* plugin_instance = 49 content::PepperPluginInstance* plugin_instance =
50 renderer_ppapi_host_->GetPluginInstance(pp_instance()); 50 renderer_ppapi_host_->GetPluginInstance(pp_instance());
51 if (!plugin_instance) 51 if (!plugin_instance)
52 return PP_ERROR_FAILED; 52 return PP_ERROR_FAILED;
53 53
54 base::FilePath plugin_dir = plugin_instance->GetModulePath().DirName(); 54 base::FilePath plugin_dir = plugin_instance->GetModulePath().DirName();
55 DCHECK(!plugin_dir.empty()); 55 DCHECK(!plugin_dir.empty());
56 base::FilePath voucher_file = plugin_dir.Append( 56 base::FilePath voucher_file = plugin_dir.Append(
57 base::FilePath(kVoucherFilename)); 57 base::FilePath(kVoucherFilename));
58 58
59 ppapi::PPB_FileRef_CreateInfo create_info; 59 IPC::Message create_msg =
60 ppapi::proxy::PPB_FileRef_Proxy::SerializeFileRef( 60 PpapiHostMsg_FileRef_CreateExternal(voucher_file);
61 plugin_instance->CreateExternalFileReference(voucher_file), 61 content::RendererPpapiHost::GetForPPInstance(pp_instance())->
62 &create_info); 62 CreateBrowserResourceHost(
63 context->reply_msg = 63 pp_instance(),
64 PpapiPluginMsg_FlashDRM_GetVoucherFileReply(create_info); 64 create_msg,
65 return PP_OK; 65 base::Bind(&PepperFlashDRMRendererHost::DidCreateResourceHost,
dmichael (off chromium) 2013/08/07 22:19:13 DidCreateFileRefHost might be a clearer name, sinc
teravest 2013/08/08 00:50:06 Done.
66 weak_factory_.GetWeakPtr(),
67 context->MakeReplyMessageContext(),
68 voucher_file));
69 return PP_OK_COMPLETIONPENDING;
70 }
71
72 void PepperFlashDRMRendererHost::DidCreateResourceHost(
73 ppapi::host::ReplyMessageContext reply_context,
74 const base::FilePath& external_path,
75 int pending_resource_id) {
76 ppapi::FileRef_CreateInfo create_info =
77 ppapi::MakeExternalFileRefCreateInfo(external_path, pending_resource_id);
78 host()->SendReply(reply_context,
79 PpapiPluginMsg_FlashDRM_GetVoucherFileReply(create_info));
66 } 80 }
67 81
68 } // namespace chrome 82 } // namespace chrome
69 83
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698