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

Unified 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, 12 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/proxy/io_stream_resource.cc
diff --git a/ppapi/proxy/io_stream_resource.cc b/ppapi/proxy/io_stream_resource.cc
new file mode 100644
index 0000000000000000000000000000000000000000..34b459cbd9b3d0803d39696717bc32997bea15e3
--- /dev/null
+++ b/ppapi/proxy/io_stream_resource.cc
@@ -0,0 +1,81 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/proxy/io_stream_resource.h"
+
+#include "ppapi/proxy/ppapi_messages.h"
+
+namespace ppapi {
+namespace proxy {
+
+IOStreamResource::IOStreamResource(Connection connection,
+ PP_Instance instance,
+ bool is_input)
+ : PluginResource(connection, instance),
+ IOStreamShared(is_input) {
+}
+
+IOStreamResource::IOStreamResource(Connection connection,
+ PP_Instance instance,
+ int pending_renderer_id,
+ bool is_input)
+ : PluginResource(connection, instance),
+ IOStreamShared(is_input) {
+ AttachToPendingHost(RENDERER, pending_renderer_id);
+}
+
+IOStreamResource::~IOStreamResource() {
+}
+
+int32_t IOStreamResource::Init(uint32_t size) {
+ if (!size)
+ return PP_ERROR_BADARGUMENT;
+ IPC::Message unused;
+ ResourceMessageReplyParams reply_params;
+ int32_t result = GenericSyncCall(RENDERER,
+ PpapiHostMsg_IOStream_Init(size), &unused, &reply_params);
+ if (result != PP_OK)
+ return result;
+
+ base::SharedMemoryHandle shm_handle = base::SharedMemory::NULLHandle();
+ reply_params.TakeSharedMemoryHandleAtIndex(0, &shm_handle);
+
+ SetBuffer(scoped_ptr<base::SharedMemory>(
+ new base::SharedMemory(shm_handle, true)), size);
+ return PP_OK;
+}
+
+void IOStreamResource::MovePeerLimit(uint32_t offset) {
+ Post(RENDERER, PpapiHostMsg_IOStream_MoveLimit(offset));
+}
+
+void IOStreamResource::OnReplyReceived(
+ const proxy::ResourceMessageReplyParams& params, const IPC::Message& msg) {
+ IPC_BEGIN_MESSAGE_MAP(IOStreamResource, msg)
+ PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
+ PpapiPluginMsg_IOStream_Init,
+ OnPluginMsgInit)
+ PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL(
+ PpapiPluginMsg_IOStream_MoveLimit,
+ OnPluginMsgMoveLimit)
+ PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED(
+ PluginResource::OnReplyReceived(params, msg))
+ IPC_END_MESSAGE_MAP()
+}
+
+void IOStreamResource::OnPluginMsgInit(
+ const ResourceMessageReplyParams& params, uint32_t size) {
+ base::SharedMemoryHandle shm_handle = base::SharedMemory::NULLHandle();
+ params.TakeSharedMemoryHandleAtIndex(0, &shm_handle);
+ SetBuffer(scoped_ptr<base::SharedMemory>(
+ 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
+}
+
+void IOStreamResource::OnPluginMsgMoveLimit(
+ const ResourceMessageReplyParams& params, uint32_t offset) {
+ MoveLimit(offset);
+}
+
+} // namespace proxy
+} // namespace ppapi

Powered by Google App Engine
This is Rietveld 408576698