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

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

Issue 23462016: Revert 219911 "Pepper: Move FileRef to the "new" resource proxy." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 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 | 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"
15 16
16 namespace chrome { 17 namespace chrome {
17 18
18 // TODO(raymes): This is duplicated from pepper_flash_drm_host.cc but once 19 // TODO(raymes): This is duplicated from pepper_flash_drm_host.cc but once
19 // FileRef is refactored to the browser, it won't need to be. 20 // FileRef is refactored to the browser, it won't need to be.
20 namespace { 21 namespace {
21 const base::FilePath::CharType kVoucherFilename[] = 22 const base::FilePath::CharType kVoucherFilename[] =
22 FILE_PATH_LITERAL("plugin.vch"); 23 FILE_PATH_LITERAL("plugin.vch");
23 } // namespace 24 } // namespace
24 25
25 PepperFlashDRMRendererHost::PepperFlashDRMRendererHost( 26 PepperFlashDRMRendererHost::PepperFlashDRMRendererHost(
26 content::RendererPpapiHost* host, 27 content::RendererPpapiHost* host,
27 PP_Instance instance, 28 PP_Instance instance,
28 PP_Resource resource) 29 PP_Resource resource)
29 : ResourceHost(host->GetPpapiHost(), instance, resource), 30 : ResourceHost(host->GetPpapiHost(), instance, resource),
30 renderer_ppapi_host_(host), 31 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 std::vector<IPC::Message> create_msgs; 59 ppapi::PPB_FileRef_CreateInfo create_info;
60 create_msgs.push_back(PpapiHostMsg_FileRef_CreateExternal(voucher_file)); 60 ppapi::proxy::PPB_FileRef_Proxy::SerializeFileRef(
61 61 plugin_instance->CreateExternalFileReference(voucher_file),
62 renderer_ppapi_host_->CreateBrowserResourceHosts( 62 &create_info);
63 pp_instance(), 63 context->reply_msg =
64 create_msgs, 64 PpapiPluginMsg_FlashDRM_GetVoucherFileReply(create_info);
65 base::Bind(&PepperFlashDRMRendererHost::DidCreateFileRefHosts, 65 return PP_OK;
66 weak_factory_.GetWeakPtr(),
67 context->MakeReplyMessageContext(),
68 voucher_file));
69 return PP_OK_COMPLETIONPENDING;
70 }
71
72 void PepperFlashDRMRendererHost::DidCreateFileRefHosts(
73 const ppapi::host::ReplyMessageContext& reply_context,
74 const base::FilePath& external_path,
75 const std::vector<int>& pending_resource_ids) {
76 DCHECK(pending_resource_ids.size() == 1);
77
78 int pending_resource_id = 0;
79 if (pending_resource_ids.size() == 1)
80 pending_resource_id = pending_resource_ids[0];
81
82 ppapi::FileRefCreateInfo create_info =
83 ppapi::MakeExternalFileRefCreateInfo(external_path,
84 std::string(),
85 pending_resource_id);
86 host()->SendReply(reply_context,
87 PpapiPluginMsg_FlashDRM_GetVoucherFileReply(create_info));
88 } 66 }
89 67
90 } // namespace chrome 68 } // namespace chrome
91 69
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698