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

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

Issue 7655002: Convert the pp::proxy namespace to the ppapi::proxy namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 namespace ppapi {
23 using ppapi::Resource;
24
25 namespace pp {
26 namespace proxy { 23 namespace proxy {
27 24
28 namespace { 25 namespace {
29 26
30 InterfaceProxy* CreateBufferProxy(Dispatcher* dispatcher, 27 InterfaceProxy* CreateBufferProxy(Dispatcher* dispatcher,
31 const void* target_interface) { 28 const void* target_interface) {
32 return new PPB_Buffer_Proxy(dispatcher, target_interface); 29 return new PPB_Buffer_Proxy(dispatcher, target_interface);
33 } 30 }
34 31
35 } // namespace 32 } // namespace
36 33
37 Buffer::Buffer(const HostResource& resource, 34 Buffer::Buffer(const HostResource& resource,
38 const base::SharedMemoryHandle& shm_handle, 35 const base::SharedMemoryHandle& shm_handle,
39 uint32_t size) 36 uint32_t size)
40 : Resource(resource), 37 : Resource(resource),
41 shm_(shm_handle, false), 38 shm_(shm_handle, false),
42 size_(size), 39 size_(size),
43 mapped_data_(NULL), 40 mapped_data_(NULL),
44 map_count_(0) { 41 map_count_(0) {
45 } 42 }
46 43
47 Buffer::~Buffer() { 44 Buffer::~Buffer() {
48 Unmap(); 45 Unmap();
49 } 46 }
50 47
51 ppapi::thunk::PPB_Buffer_API* Buffer::AsPPB_Buffer_API() { 48 thunk::PPB_Buffer_API* Buffer::AsPPB_Buffer_API() {
52 return this; 49 return this;
53 } 50 }
54 51
55 PP_Bool Buffer::Describe(uint32_t* size_in_bytes) { 52 PP_Bool Buffer::Describe(uint32_t* size_in_bytes) {
56 *size_in_bytes = size_; 53 *size_in_bytes = size_;
57 return PP_TRUE; 54 return PP_TRUE;
58 } 55 }
59 56
60 PP_Bool Buffer::IsMapped() { 57 PP_Bool Buffer::IsMapped() {
61 return PP_FromBool(!!mapped_data_); 58 return PP_FromBool(!!mapped_data_);
(...skipping 14 matching lines...) Expand all
76 const void* target_interface) 73 const void* target_interface)
77 : InterfaceProxy(dispatcher, target_interface) { 74 : InterfaceProxy(dispatcher, target_interface) {
78 } 75 }
79 76
80 PPB_Buffer_Proxy::~PPB_Buffer_Proxy() { 77 PPB_Buffer_Proxy::~PPB_Buffer_Proxy() {
81 } 78 }
82 79
83 // static 80 // static
84 const InterfaceProxy::Info* PPB_Buffer_Proxy::GetInfo() { 81 const InterfaceProxy::Info* PPB_Buffer_Proxy::GetInfo() {
85 static const Info info = { 82 static const Info info = {
86 ppapi::thunk::GetPPB_Buffer_Thunk(), 83 thunk::GetPPB_Buffer_Thunk(),
87 PPB_BUFFER_DEV_INTERFACE, 84 PPB_BUFFER_DEV_INTERFACE,
88 INTERFACE_ID_PPB_BUFFER, 85 INTERFACE_ID_PPB_BUFFER,
89 false, 86 false,
90 &CreateBufferProxy, 87 &CreateBufferProxy,
91 }; 88 };
92 return &info; 89 return &info;
93 } 90 }
94 91
95 // static 92 // static
96 PP_Resource PPB_Buffer_Proxy::CreateProxyResource(PP_Instance instance, 93 PP_Resource PPB_Buffer_Proxy::CreateProxyResource(PP_Instance instance,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 base::SharedMemoryHandle* result_shm_handle) { 132 base::SharedMemoryHandle* result_shm_handle) {
136 // Overwritten below on success. 133 // Overwritten below on success.
137 *result_shm_handle = base::SharedMemory::NULLHandle(); 134 *result_shm_handle = base::SharedMemory::NULLHandle();
138 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance); 135 HostDispatcher* dispatcher = HostDispatcher::GetForInstance(instance);
139 if (!dispatcher) 136 if (!dispatcher)
140 return; 137 return;
141 PP_Resource local_buffer_resource = 138 PP_Resource local_buffer_resource =
142 ppb_buffer_target()->Create(instance, size); 139 ppb_buffer_target()->Create(instance, size);
143 if (local_buffer_resource == 0) 140 if (local_buffer_resource == 0)
144 return; 141 return;
145 ::ppapi::thunk::EnterResourceNoLock< ::ppapi::thunk::PPB_BufferTrusted_API> 142 thunk::EnterResourceNoLock<thunk::PPB_BufferTrusted_API> trusted_buffer(
146 trusted_buffer(local_buffer_resource, false); 143 local_buffer_resource, false);
147 if (trusted_buffer.failed()) 144 if (trusted_buffer.failed())
148 return; 145 return;
149 int local_fd; 146 int local_fd;
150 if (trusted_buffer.object()->GetSharedMemory(&local_fd) != PP_OK) 147 if (trusted_buffer.object()->GetSharedMemory(&local_fd) != PP_OK)
151 return; 148 return;
152 149
153 result_resource->SetHostResource(instance, local_buffer_resource); 150 result_resource->SetHostResource(instance, local_buffer_resource);
154 151
155 // TODO(piman/brettw): Change trusted interface to return a PP_FileHandle, 152 // TODO(piman/brettw): Change trusted interface to return a PP_FileHandle,
156 // those casts are ugly. 153 // those casts are ugly.
157 base::PlatformFile platform_file = 154 base::PlatformFile platform_file =
158 #if defined(OS_WIN) 155 #if defined(OS_WIN)
159 reinterpret_cast<HANDLE>(static_cast<intptr_t>(local_fd)); 156 reinterpret_cast<HANDLE>(static_cast<intptr_t>(local_fd));
160 #elif defined(OS_POSIX) 157 #elif defined(OS_POSIX)
161 local_fd; 158 local_fd;
162 #else 159 #else
163 #error Not implemented. 160 #error Not implemented.
164 #endif 161 #endif
165 *result_shm_handle = dispatcher->ShareHandleWithRemote(platform_file, false); 162 *result_shm_handle = dispatcher->ShareHandleWithRemote(platform_file, false);
166 } 163 }
167 164
168 } // namespace proxy 165 } // namespace proxy
169 } // namespace pp 166 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698