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

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: Another rebase 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"
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 int renderer_pending_host_id =
60 ppapi::proxy::PPB_FileRef_Proxy::SerializeFileRef( 60 plugin_instance->MakePendingFileRefRendererHost(voucher_file);
61 plugin_instance->CreateExternalFileReference(voucher_file), 61 if (renderer_pending_host_id == 0)
62 &create_info); 62 return PP_ERROR_FAILED;
63 context->reply_msg = 63
64 PpapiPluginMsg_FlashDRM_GetVoucherFileReply(create_info); 64 std::vector<IPC::Message> create_msgs;
65 return PP_OK; 65 create_msgs.push_back(PpapiHostMsg_FileRef_CreateExternal(voucher_file));
66
67 renderer_ppapi_host_->CreateBrowserResourceHosts(
68 pp_instance(),
69 create_msgs,
70 base::Bind(&PepperFlashDRMRendererHost::DidCreateFileRefHosts,
71 weak_factory_.GetWeakPtr(),
72 context->MakeReplyMessageContext(),
73 voucher_file,
74 renderer_pending_host_id));
75 return PP_OK_COMPLETIONPENDING;
76 }
77
78 void PepperFlashDRMRendererHost::DidCreateFileRefHosts(
79 const ppapi::host::ReplyMessageContext& reply_context,
80 const base::FilePath& external_path,
81 int renderer_pending_host_id,
82 const std::vector<int>& browser_pending_host_ids) {
83 DCHECK(browser_pending_host_ids.size() == 1);
84
85 int browser_pending_host_id = 0;
86 if (browser_pending_host_ids.size() == 1)
87 browser_pending_host_id = browser_pending_host_ids[0];
88
89 ppapi::FileRefCreateInfo create_info =
90 ppapi::MakeExternalFileRefCreateInfo(external_path,
91 std::string(),
92 browser_pending_host_id,
93 renderer_pending_host_id);
94 host()->SendReply(reply_context,
95 PpapiPluginMsg_FlashDRM_GetVoucherFileReply(create_info));
66 } 96 }
67 97
68 } // namespace chrome 98 } // namespace chrome
69 99
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698