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

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) 2014 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 is_input)
15 : PluginResource(connection, instance),
16 IOStreamShared(is_input) {
17 }
18
19 IOStreamResource::IOStreamResource(Connection connection,
20 PP_Instance instance,
21 int pending_renderer_id,
22 bool is_input)
23 : PluginResource(connection, instance),
24 IOStreamShared(is_input) {
25 AttachToPendingHost(RENDERER, pending_renderer_id);
26 }
27
28 IOStreamResource::~IOStreamResource() {
29 }
30
31 int32_t IOStreamResource::Init(uint32_t size) {
32 if (!size)
33 return PP_ERROR_BADARGUMENT;
34 IPC::Message unused;
35 ResourceMessageReplyParams reply_params;
36 int32_t result = GenericSyncCall(RENDERER,
37 PpapiHostMsg_IOStream_Init(size), &unused, &reply_params);
38 if (result != PP_OK)
39 return result;
40
41 base::SharedMemoryHandle shm_handle = base::SharedMemory::NULLHandle();
42 reply_params.TakeSharedMemoryHandleAtIndex(0, &shm_handle);
43
44 SetBuffer(scoped_ptr<base::SharedMemory>(
45 new base::SharedMemory(shm_handle, true)), size);
46 return PP_OK;
47 }
48
49 void IOStreamResource::MovePeerLimit(uint32_t offset) {
50 Post(RENDERER, PpapiHostMsg_IOStream_MoveLimit(offset));
51 }
52
53 void IOStreamResource::OnReplyReceived(
54 const proxy::ResourceMessageReplyParams& params, const IPC::Message& msg) {
55 IPC_BEGIN_MESSAGE_MAP(IOStreamResource, msg)
56 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
57 PpapiPluginMsg_IOStream_Init,
58 OnPluginMsgInit)
59 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
60 PpapiPluginMsg_IOStream_MoveLimit,
61 OnPluginMsgMoveLimit)
62 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(
63 PluginResource::OnReplyReceived(params, msg))
64 IPC_END_MESSAGE_MAP()
65 }
66
67 void IOStreamResource::OnPluginMsgInit(
68 const ResourceMessageReplyParams& params, uint32_t size) {
69 base::SharedMemoryHandle shm_handle = base::SharedMemory::NULLHandle();
70 params.TakeSharedMemoryHandleAtIndex(0, &shm_handle);
71 SetBuffer(scoped_ptr<base::SharedMemory>(
72 new base::SharedMemory(shm_handle, is_input())), size);
bbudge 2014/01/02 22:16:22 indentation
Peng 2014/01/03 16:15:11 The vim editor gives it 6 spaces intent. In this c
73 }
74
75 void IOStreamResource::OnPluginMsgMoveLimit(
76 const ResourceMessageReplyParams& params, uint32_t offset) {
77 MoveLimit(offset);
78 }
79
80 } // namespace proxy
81 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698