Chromium Code Reviews| 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 // static | |
|
brettw
2011/08/08 22:42:17
Blank line before this.
piman
2011/08/09 02:31:39
Done.
| |
| 114 PP_Resource PPB_Buffer_Proxy::AddProxyResource( | |
| 115 const HostResource& resource, | |
| 116 base::SharedMemoryHandle shm_handle, | |
| 117 uint32_t size) { | |
| 118 linked_ptr<Buffer> object(new Buffer(resource, shm_handle, size)); | |
| 112 return PluginResourceTracker::GetInstance()->AddResource(object); | 119 return PluginResourceTracker::GetInstance()->AddResource(object); |
| 113 } | 120 } |
| 114 | 121 |
| 115 bool PPB_Buffer_Proxy::OnMessageReceived(const IPC::Message& msg) { | 122 bool PPB_Buffer_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 116 bool handled = true; | 123 bool handled = true; |
| 117 IPC_BEGIN_MESSAGE_MAP(PPB_Buffer_Proxy, msg) | 124 IPC_BEGIN_MESSAGE_MAP(PPB_Buffer_Proxy, msg) |
| 118 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBBuffer_Create, OnMsgCreate) | 125 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBBuffer_Create, OnMsgCreate) |
| 119 IPC_MESSAGE_UNHANDLED(handled = false) | 126 IPC_MESSAGE_UNHANDLED(handled = false) |
| 120 IPC_END_MESSAGE_MAP() | 127 IPC_END_MESSAGE_MAP() |
| 121 // TODO(brettw) handle bad messages! | 128 // TODO(brettw) handle bad messages! |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 #elif defined(OS_POSIX) | 161 #elif defined(OS_POSIX) |
| 155 local_fd; | 162 local_fd; |
| 156 #else | 163 #else |
| 157 #error Not implemented. | 164 #error Not implemented. |
| 158 #endif | 165 #endif |
| 159 *result_shm_handle = dispatcher->ShareHandleWithRemote(platform_file, false); | 166 *result_shm_handle = dispatcher->ShareHandleWithRemote(platform_file, false); |
| 160 } | 167 } |
| 161 | 168 |
| 162 } // namespace proxy | 169 } // namespace proxy |
| 163 } // namespace pp | 170 } // namespace pp |
| OLD | NEW |