OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ppapi/proxy/ppb_buffer_proxy.h" | 5 #include "ppapi/proxy/ppb_buffer_proxy.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 return 0; | 101 return 0; |
102 | 102 |
103 HostResource result; | 103 HostResource result; |
104 base::SharedMemoryHandle shm_handle = base::SharedMemory::NULLHandle(); | 104 base::SharedMemoryHandle shm_handle = base::SharedMemory::NULLHandle(); |
105 dispatcher->Send(new PpapiHostMsg_PPBBuffer_Create( | 105 dispatcher->Send(new PpapiHostMsg_PPBBuffer_Create( |
106 INTERFACE_ID_PPB_BUFFER, instance, size, | 106 INTERFACE_ID_PPB_BUFFER, instance, size, |
107 &result, &shm_handle)); | 107 &result, &shm_handle)); |
108 if (result.is_null() || !base::SharedMemory::IsHandleValid(shm_handle)) | 108 if (result.is_null() || !base::SharedMemory::IsHandleValid(shm_handle)) |
109 return 0; | 109 return 0; |
110 | 110 |
111 linked_ptr<Buffer> object(new Buffer(result, shm_handle, size)); | 111 return AddProxyResource(result, shm_handle, size); |
| 112 } |
| 113 |
| 114 // static |
| 115 PP_Resource PPB_Buffer_Proxy::AddProxyResource( |
| 116 const HostResource& resource, |
| 117 base::SharedMemoryHandle shm_handle, |
| 118 uint32_t size) { |
| 119 linked_ptr<Buffer> object(new Buffer(resource, shm_handle, size)); |
112 return PluginResourceTracker::GetInstance()->AddResource(object); | 120 return PluginResourceTracker::GetInstance()->AddResource(object); |
113 } | 121 } |
114 | 122 |
115 bool PPB_Buffer_Proxy::OnMessageReceived(const IPC::Message& msg) { | 123 bool PPB_Buffer_Proxy::OnMessageReceived(const IPC::Message& msg) { |
116 bool handled = true; | 124 bool handled = true; |
117 IPC_BEGIN_MESSAGE_MAP(PPB_Buffer_Proxy, msg) | 125 IPC_BEGIN_MESSAGE_MAP(PPB_Buffer_Proxy, msg) |
118 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBBuffer_Create, OnMsgCreate) | 126 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBBuffer_Create, OnMsgCreate) |
119 IPC_MESSAGE_UNHANDLED(handled = false) | 127 IPC_MESSAGE_UNHANDLED(handled = false) |
120 IPC_END_MESSAGE_MAP() | 128 IPC_END_MESSAGE_MAP() |
121 // TODO(brettw) handle bad messages! | 129 // TODO(brettw) handle bad messages! |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 #elif defined(OS_POSIX) | 162 #elif defined(OS_POSIX) |
155 local_fd; | 163 local_fd; |
156 #else | 164 #else |
157 #error Not implemented. | 165 #error Not implemented. |
158 #endif | 166 #endif |
159 *result_shm_handle = dispatcher->ShareHandleWithRemote(platform_file, false); | 167 *result_shm_handle = dispatcher->ShareHandleWithRemote(platform_file, false); |
160 } | 168 } |
161 | 169 |
162 } // namespace proxy | 170 } // namespace proxy |
163 } // namespace pp | 171 } // namespace pp |
OLD | NEW |