| OLD | NEW |
| 1 // Copyright (c) 2010 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" |
| 11 #include "ppapi/c/pp_completion_callback.h" | 11 #include "ppapi/c/pp_completion_callback.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 return NULL; | 102 return NULL; |
| 103 return object->Map(); | 103 return object->Map(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void Unmap(PP_Resource resource) { | 106 void Unmap(PP_Resource resource) { |
| 107 Buffer* object = PluginResource::GetAs<Buffer>(resource); | 107 Buffer* object = PluginResource::GetAs<Buffer>(resource); |
| 108 if (object) | 108 if (object) |
| 109 object->Unmap(); | 109 object->Unmap(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 const PPB_Buffer_Dev ppb_buffer = { | 112 const PPB_Buffer_Dev buffer_interface = { |
| 113 &Create, | 113 &Create, |
| 114 &IsBuffer, | 114 &IsBuffer, |
| 115 &Describe, | 115 &Describe, |
| 116 &Map, | 116 &Map, |
| 117 &Unmap, | 117 &Unmap, |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 InterfaceProxy* CreateBufferProxy(Dispatcher* dispatcher, |
| 121 const void* target_interface) { |
| 122 return new PPB_Buffer_Proxy(dispatcher, target_interface); |
| 123 } |
| 124 |
| 120 } // namespace | 125 } // namespace |
| 121 | 126 |
| 122 PPB_Buffer_Proxy::PPB_Buffer_Proxy(Dispatcher* dispatcher, | 127 PPB_Buffer_Proxy::PPB_Buffer_Proxy(Dispatcher* dispatcher, |
| 123 const void* target_interface) | 128 const void* target_interface) |
| 124 : InterfaceProxy(dispatcher, target_interface) { | 129 : InterfaceProxy(dispatcher, target_interface) { |
| 125 } | 130 } |
| 126 | 131 |
| 127 PPB_Buffer_Proxy::~PPB_Buffer_Proxy() { | 132 PPB_Buffer_Proxy::~PPB_Buffer_Proxy() { |
| 128 } | 133 } |
| 129 | 134 |
| 130 const void* PPB_Buffer_Proxy::GetSourceInterface() const { | 135 // static |
| 131 return &ppb_buffer; | 136 const InterfaceProxy::Info* PPB_Buffer_Proxy::GetInfo() { |
| 132 } | 137 static const Info info = { |
| 133 | 138 &buffer_interface, |
| 134 InterfaceID PPB_Buffer_Proxy::GetInterfaceId() const { | 139 PPB_BUFFER_DEV_INTERFACE, |
| 135 return INTERFACE_ID_PPB_BUFFER; | 140 INTERFACE_ID_PPB_BUFFER, |
| 141 false, |
| 142 &CreateBufferProxy, |
| 143 }; |
| 144 return &info; |
| 136 } | 145 } |
| 137 | 146 |
| 138 bool PPB_Buffer_Proxy::OnMessageReceived(const IPC::Message& msg) { | 147 bool PPB_Buffer_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 139 bool handled = true; | 148 bool handled = true; |
| 140 IPC_BEGIN_MESSAGE_MAP(PPB_Buffer_Proxy, msg) | 149 IPC_BEGIN_MESSAGE_MAP(PPB_Buffer_Proxy, msg) |
| 141 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBBuffer_Create, OnMsgCreate) | 150 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBBuffer_Create, OnMsgCreate) |
| 142 IPC_MESSAGE_UNHANDLED(handled = false) | 151 IPC_MESSAGE_UNHANDLED(handled = false) |
| 143 IPC_END_MESSAGE_MAP() | 152 IPC_END_MESSAGE_MAP() |
| 144 // TODO(brettw) handle bad messages! | 153 // TODO(brettw) handle bad messages! |
| 145 return handled; | 154 return handled; |
| 146 } | 155 } |
| 147 | 156 |
| 148 void PPB_Buffer_Proxy::OnMsgCreate(PP_Instance instance, | 157 void PPB_Buffer_Proxy::OnMsgCreate(PP_Instance instance, |
| 149 uint32_t size, | 158 uint32_t size, |
| 150 HostResource* result_resource, | 159 HostResource* result_resource, |
| 151 int* result_shm_handle) { | 160 int* result_shm_handle) { |
| 152 result_resource->SetHostResource( | 161 result_resource->SetHostResource( |
| 153 instance, | 162 instance, |
| 154 ppb_buffer_target()->Create(instance, size)); | 163 ppb_buffer_target()->Create(instance, size)); |
| 155 // TODO(brettw) set the shm handle from a trusted interface. | 164 // TODO(brettw) set the shm handle from a trusted interface. |
| 156 *result_shm_handle = 0; | 165 *result_shm_handle = 0; |
| 157 } | 166 } |
| 158 | 167 |
| 159 } // namespace proxy | 168 } // namespace proxy |
| 160 } // namespace pp | 169 } // namespace pp |
| OLD | NEW |