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

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

Issue 119853003: [PPAPI] Implement an IOStreamResource for data transmission between plugin and renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update Created 6 years, 11 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/io_stream_resource.h"
6
7 #include "ppapi/proxy/ppapi_messages.h"
8
9 namespace ppapi {
10 namespace proxy {
11
12 IOStreamResource::IOStreamResource(Connection connection,
13 PP_Instance instance,
14 bool input)
15 : PluginResource(connection, instance),
16 IOStreamShared(input) {
17 }
18
19 IOStreamResource::IOStreamResource(Connection connection,
20 PP_Instance instance,
21 int pending_renderer_id,
22 bool input)
23 : PluginResource(connection, instance),
24 IOStreamShared(input) {
25 AttachToPendingHost(RENDERER, pending_renderer_id);
26 }
27
28 IOStreamResource::~IOStreamResource() {
29 }
30
31 int32_t IOStreamResource::Init(uint32_t size) {
32 CHECK(size);
bbudge 2013/12/31 00:51:53 You should probably return PP_ERROR_BADARGUMENT in
Peng 2013/12/31 23:33:54 Done.
33 IPC::Message unused;
34 ResourceMessageReplyParams reply_params;
35 int32_t result = GenericSyncCall(RENDERER,
36 PpapiHostMsg_IOStream_Init(size), &unused, &reply_params);
37 if (result != PP_OK)
38 return result;
39
40 base::SharedMemoryHandle shm_handle = base::SharedMemory::NULLHandle();
41 reply_params.TakeSharedMemoryHandleAtIndex(0, &shm_handle);
42
43 SetBuffer(scoped_ptr<base::SharedMemory>(
44 new base::SharedMemory(shm_handle, true)), size);
45 return PP_OK;
46 }
47
48 void IOStreamResource::MovePeerLimit(uint32_t offset) {
49 Post(RENDERER, PpapiHostMsg_IOStream_MoveLimit(offset));
50 }
51
52 void IOStreamResource::OnReplyReceived(
53 const proxy::ResourceMessageReplyParams& params, const IPC::Message& msg) {
54 IPC_BEGIN_MESSAGE_MAP(IOStreamResource, msg)
55 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
56 PpapiPluginMsg_IOStream_Init,
57 OnPluginMsgInit)
58 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
59 PpapiPluginMsg_IOStream_MoveLimit,
60 OnPluginMsgMoveLimit)
61 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(
62 PluginResource::OnReplyReceived(params, msg))
63 IPC_END_MESSAGE_MAP()
64 }
65
66 void IOStreamResource::OnPluginMsgInit(
67 const ResourceMessageReplyParams& params, uint32_t size) {
68 base::SharedMemoryHandle shm_handle = base::SharedMemory::NULLHandle();
69 params.TakeSharedMemoryHandleAtIndex(0, &shm_handle);
70 SetBuffer(scoped_ptr<base::SharedMemory>(
71 new base::SharedMemory(shm_handle, input())), size);
72 }
73
74 void IOStreamResource::OnPluginMsgMoveLimit(
75 const ResourceMessageReplyParams& params, uint32_t offset) {
76 MoveLimit(offset);
77 }
78
79 } // namespace proxy
80 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698