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

Side by Side Diff: ppapi/proxy/ppb_buffer_proxy.cc

Issue 7629017: Add a unified resource tracker shared between the proxy and the impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Assertion fixed Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "ppapi/c/pp_completion_callback.h" 11 #include "ppapi/c/pp_completion_callback.h"
12 #include "ppapi/c/pp_errors.h" 12 #include "ppapi/c/pp_errors.h"
13 #include "ppapi/c/pp_resource.h" 13 #include "ppapi/c/pp_resource.h"
14 #include "ppapi/c/dev/ppb_buffer_dev.h" 14 #include "ppapi/c/dev/ppb_buffer_dev.h"
15 #include "ppapi/proxy/host_dispatcher.h" 15 #include "ppapi/proxy/host_dispatcher.h"
16 #include "ppapi/proxy/plugin_dispatcher.h" 16 #include "ppapi/proxy/plugin_dispatcher.h"
17 #include "ppapi/proxy/ppapi_messages.h" 17 #include "ppapi/proxy/ppapi_messages.h"
18 #include "ppapi/thunk/enter.h" 18 #include "ppapi/thunk/enter.h"
19 #include "ppapi/thunk/ppb_buffer_trusted_api.h" 19 #include "ppapi/thunk/ppb_buffer_trusted_api.h"
20 #include "ppapi/thunk/thunk.h" 20 #include "ppapi/thunk/thunk.h"
21 21
22 using ppapi::HostResource; 22 using ppapi::HostResource;
23 using ppapi::Resource;
23 24
24 namespace pp { 25 namespace pp {
25 namespace proxy { 26 namespace proxy {
26 27
27 namespace { 28 namespace {
28 29
29 InterfaceProxy* CreateBufferProxy(Dispatcher* dispatcher, 30 InterfaceProxy* CreateBufferProxy(Dispatcher* dispatcher,
30 const void* target_interface) { 31 const void* target_interface) {
31 return new PPB_Buffer_Proxy(dispatcher, target_interface); 32 return new PPB_Buffer_Proxy(dispatcher, target_interface);
32 } 33 }
33 34
34 } // namespace 35 } // namespace
35 36
36 Buffer::Buffer(const HostResource& resource, 37 Buffer::Buffer(const HostResource& resource,
37 const base::SharedMemoryHandle& shm_handle, 38 const base::SharedMemoryHandle& shm_handle,
38 uint32_t size) 39 uint32_t size)
39 : PluginResource(resource), 40 : Resource(resource),
40 shm_(shm_handle, false), 41 shm_(shm_handle, false),
41 size_(size), 42 size_(size),
42 mapped_data_(NULL), 43 mapped_data_(NULL),
43 map_count_(0) { 44 map_count_(0) {
44 } 45 }
45 46
46 Buffer::~Buffer() { 47 Buffer::~Buffer() {
47 Unmap(); 48 Unmap();
48 } 49 }
49 50
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 return 0; 108 return 0;
108 109
109 return AddProxyResource(result, shm_handle, size); 110 return AddProxyResource(result, shm_handle, size);
110 } 111 }
111 112
112 // static 113 // static
113 PP_Resource PPB_Buffer_Proxy::AddProxyResource( 114 PP_Resource PPB_Buffer_Proxy::AddProxyResource(
114 const HostResource& resource, 115 const HostResource& resource,
115 base::SharedMemoryHandle shm_handle, 116 base::SharedMemoryHandle shm_handle,
116 uint32_t size) { 117 uint32_t size) {
117 return PluginResourceTracker::GetInstance()->AddResource( 118 return (new Buffer(resource, shm_handle, size))->GetReference();
118 new Buffer(resource, shm_handle, size));
119 } 119 }
120 120
121 bool PPB_Buffer_Proxy::OnMessageReceived(const IPC::Message& msg) { 121 bool PPB_Buffer_Proxy::OnMessageReceived(const IPC::Message& msg) {
122 bool handled = true; 122 bool handled = true;
123 IPC_BEGIN_MESSAGE_MAP(PPB_Buffer_Proxy, msg) 123 IPC_BEGIN_MESSAGE_MAP(PPB_Buffer_Proxy, msg)
124 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBBuffer_Create, OnMsgCreate) 124 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBBuffer_Create, OnMsgCreate)
125 IPC_MESSAGE_UNHANDLED(handled = false) 125 IPC_MESSAGE_UNHANDLED(handled = false)
126 IPC_END_MESSAGE_MAP() 126 IPC_END_MESSAGE_MAP()
127 // TODO(brettw) handle bad messages! 127 // TODO(brettw) handle bad messages!
128 return handled; 128 return handled;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 #elif defined(OS_POSIX) 160 #elif defined(OS_POSIX)
161 local_fd; 161 local_fd;
162 #else 162 #else
163 #error Not implemented. 163 #error Not implemented.
164 #endif 164 #endif
165 *result_shm_handle = dispatcher->ShareHandleWithRemote(platform_file, false); 165 *result_shm_handle = dispatcher->ShareHandleWithRemote(platform_file, false);
166 } 166 }
167 167
168 } // namespace proxy 168 } // namespace proxy
169 } // namespace pp 169 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698