Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 "base/bind.h" | |
| 8 #include "ppapi/proxy/ppapi_messages.h" | |
| 9 | |
| 10 namespace ppapi { | |
| 11 namespace proxy { | |
| 12 | |
| 13 IOStreamResource::IOStreamResource(Connection connection, | |
| 14 PP_Instance instance, | |
| 15 bool is_input) | |
| 16 : PluginResource(connection, instance), | |
| 17 IOStreamShared(is_input), | |
| 18 weak_factory_(this) { | |
| 19 } | |
| 20 | |
| 21 IOStreamResource::IOStreamResource(Connection connection, | |
| 22 PP_Instance instance, | |
| 23 int pending_renderer_id, | |
| 24 bool is_input) | |
| 25 : PluginResource(connection, instance), | |
| 26 IOStreamShared(is_input), | |
| 27 weak_factory_(this) { | |
| 28 AttachToPendingHost(RENDERER, pending_renderer_id); | |
| 29 } | |
| 30 | |
| 31 IOStreamResource::~IOStreamResource() { | |
| 32 } | |
| 33 | |
| 34 int32_t IOStreamResource::Init(uint32_t size, | |
| 35 scoped_refptr<TrackedCallback> callback) { | |
| 36 if (!size) | |
| 37 return PP_ERROR_BADARGUMENT; | |
| 38 Call<PpapiPluginMsg_IOStream_InitReply>( | |
| 39 RENDERER, PpapiHostMsg_IOStream_Init(size), | |
| 40 base::Bind( | |
| 41 &IOStreamResource::OnPluginMsgInitReply, | |
| 42 weak_factory_.GetWeakPtr(), size, callback)); | |
|
yzshen1
2014/01/03 21:51:41
You don't need this weak_factory_. You could use b
| |
| 43 | |
| 44 return PP_OK_COMPLETIONPENDING; | |
| 45 } | |
| 46 | |
| 47 void IOStreamResource::MovePeerLimit(uint32_t offset) { | |
| 48 Post(RENDERER, PpapiHostMsg_IOStream_MoveLimit(offset)); | |
| 49 } | |
| 50 | |
| 51 void IOStreamResource::OnReplyReceived( | |
| 52 const proxy::ResourceMessageReplyParams& params, const IPC::Message& msg) { | |
|
yzshen1
2014/01/03 21:51:41
proxy:: is not needed.
| |
| 53 IPC_BEGIN_MESSAGE_MAP(IOStreamResource, msg) | |
| 54 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL( | |
| 55 PpapiPluginMsg_IOStream_Init, | |
| 56 OnPluginMsgInit) | |
| 57 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL( | |
| 58 PpapiPluginMsg_IOStream_MoveLimit, | |
| 59 OnPluginMsgMoveLimit) | |
| 60 PPAPI_DISPATCH_PLUGIN_RESOURCE_CALL_UNHANDLED( | |
| 61 PluginResource::OnReplyReceived(params, msg)) | |
| 62 IPC_END_MESSAGE_MAP() | |
| 63 } | |
| 64 | |
| 65 void IOStreamResource::OnPluginMsgInit( | |
| 66 const ResourceMessageReplyParams& params, uint32_t size) { | |
|
dmichael (off chromium)
2014/01/03 18:05:29
Why is this "ResourceMessageReplyParams" instead o
yzshen1
2014/01/03 21:51:41
I thought we always use ResourceMessageReplyParams
| |
| 67 base::SharedMemoryHandle shm_handle = base::SharedMemory::NULLHandle(); | |
| 68 params.TakeSharedMemoryHandleAtIndex(0, &shm_handle); | |
| 69 SetBuffer(scoped_ptr<base::SharedMemory>( | |
|
dmichael (off chromium)
2014/01/03 18:05:29
Note I think this is only ever changing from an em
Peng
2014/01/03 21:01:49
Actually this function can be used more than once.
| |
| 70 new base::SharedMemory(shm_handle, is_input())), size); | |
|
yzshen1
2014/01/03 21:51:41
wrong indent
| |
| 71 } | |
| 72 | |
| 73 void IOStreamResource::OnPluginMsgMoveLimit( | |
| 74 const ResourceMessageReplyParams& params, uint32_t offset) { | |
| 75 MoveLimit(offset); | |
| 76 } | |
| 77 | |
| 78 void IOStreamResource::OnPluginMsgInitReply( | |
|
dmichael (off chromium)
2014/01/03 18:05:29
Am I understanding correctly that there are two di
Peng
2014/01/03 21:01:49
There are different requirements for Track & Produ
| |
| 79 uint32_t size, | |
| 80 scoped_refptr<TrackedCallback> callback, | |
| 81 const ResourceMessageReplyParams& params) { | |
| 82 int32_t result = params.result(); | |
| 83 if (result == PP_OK) | |
| 84 OnPluginMsgInit(params, size); | |
| 85 callback->Run(result);; | |
|
dmichael (off chromium)
2014/01/03 18:05:29
nit: extra semicolon
| |
| 86 } | |
| 87 | |
| 88 } // namespace proxy | |
| 89 } // namespace ppapi | |
| OLD | NEW |