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

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

Issue 5410001: Change trusted shared memory interface to match audio.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years 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
« no previous file with comments | « ppapi/proxy/ppb_buffer_proxy.h ('k') | ppapi/proxy/ppb_image_data_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_resource.h" 12 #include "ppapi/c/pp_resource.h"
13 #include "ppapi/c/dev/ppb_buffer_dev.h" 13 #include "ppapi/c/dev/ppb_buffer_dev.h"
14 #include "ppapi/proxy/plugin_dispatcher.h" 14 #include "ppapi/proxy/plugin_dispatcher.h"
15 #include "ppapi/proxy/plugin_resource.h" 15 #include "ppapi/proxy/plugin_resource.h"
16 #include "ppapi/proxy/ppapi_messages.h" 16 #include "ppapi/proxy/ppapi_messages.h"
17 17
18 namespace pp { 18 namespace pp {
19 namespace proxy { 19 namespace proxy {
20 20
21 class Buffer : public PluginResource { 21 class Buffer : public PluginResource {
22 public: 22 public:
23 Buffer(uint64_t memory_handle, int32_t size); 23 Buffer(int memory_handle, uint32_t size);
24 virtual ~Buffer(); 24 virtual ~Buffer();
25 25
26 // Resource overrides. 26 // Resource overrides.
27 virtual Buffer* AsBuffer() { return this; } 27 virtual Buffer* AsBuffer() { return this; }
28 28
29 int32_t size() const { return size_; } 29 uint32_t size() const { return size_; }
30 30
31 void* Map(); 31 void* Map();
32 void Unmap(); 32 void Unmap();
33 33
34 private: 34 private:
35 uint64_t memory_handle_; 35 int memory_handle_;
36 int32_t size_; 36 uint32_t size_;
37 37
38 void* mapped_data_; 38 void* mapped_data_;
39 39
40 DISALLOW_COPY_AND_ASSIGN(Buffer); 40 DISALLOW_COPY_AND_ASSIGN(Buffer);
41 }; 41 };
42 42
43 Buffer::Buffer(uint64_t memory_handle, int32_t size) 43 Buffer::Buffer(int memory_handle, uint32_t size)
44 : memory_handle_(memory_handle), 44 : memory_handle_(memory_handle),
45 size_(size), 45 size_(size),
46 mapped_data_(NULL) { 46 mapped_data_(NULL) {
47 } 47 }
48 48
49 Buffer::~Buffer() { 49 Buffer::~Buffer() {
50 Unmap(); 50 Unmap();
51 } 51 }
52 52
53 void* Buffer::Map() { 53 void* Buffer::Map() {
54 // TODO(brettw) implement this. 54 // TODO(brettw) implement this.
55 return mapped_data_; 55 return mapped_data_;
56 } 56 }
57 57
58 void Buffer::Unmap() { 58 void Buffer::Unmap() {
59 // TODO(brettw) implement this. 59 // TODO(brettw) implement this.
60 } 60 }
61 61
62 namespace { 62 namespace {
63 63
64 PP_Resource Create(PP_Module module_id, int32_t size) { 64 PP_Resource Create(PP_Module module_id, uint32_t size) {
65 PP_Resource result = 0; 65 PP_Resource result = 0;
66 uint64_t shm_handle = -1; 66 int32_t shm_handle = -1;
67 PluginDispatcher::Get()->Send( 67 PluginDispatcher::Get()->Send(
68 new PpapiHostMsg_PPBBuffer_Create( 68 new PpapiHostMsg_PPBBuffer_Create(
69 INTERFACE_ID_PPB_BUFFER, module_id, size, 69 INTERFACE_ID_PPB_BUFFER, module_id, size,
70 &result, &shm_handle)); 70 &result, &shm_handle));
71 if (!result) 71 if (!result)
72 return 0; 72 return 0;
73 73
74 linked_ptr<Buffer> object(new Buffer(shm_handle, size)); 74 linked_ptr<Buffer> object(new Buffer(static_cast<int>(shm_handle), size));
75 PluginDispatcher::Get()->plugin_resource_tracker()->AddResource( 75 PluginDispatcher::Get()->plugin_resource_tracker()->AddResource(
76 result, object); 76 result, object);
77 return result; 77 return result;
78 } 78 }
79 79
80 PP_Bool IsBuffer(PP_Resource resource) { 80 PP_Bool IsBuffer(PP_Resource resource) {
81 Buffer* object = PluginResource::GetAs<Buffer>(resource); 81 Buffer* object = PluginResource::GetAs<Buffer>(resource);
82 return BoolToPPBool(!!object); 82 return BoolToPPBool(!!object);
83 } 83 }
84 84
85 PP_Bool Describe(PP_Resource resource, int32_t* size_in_bytes) { 85 PP_Bool Describe(PP_Resource resource, uint32_t* size_in_bytes) {
86 Buffer* object = PluginResource::GetAs<Buffer>(resource); 86 Buffer* object = PluginResource::GetAs<Buffer>(resource);
87 if (!object) { 87 if (!object) {
88 *size_in_bytes = 0; 88 *size_in_bytes = 0;
89 return PP_FALSE; 89 return PP_FALSE;
90 } 90 }
91 *size_in_bytes = object->size(); 91 *size_in_bytes = object->size();
92 return PP_TRUE; 92 return PP_TRUE;
93 } 93 }
94 94
95 void* Map(PP_Resource resource) { 95 void* Map(PP_Resource resource) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 132 }
133 133
134 void PPB_Buffer_Proxy::OnMessageReceived(const IPC::Message& msg) { 134 void PPB_Buffer_Proxy::OnMessageReceived(const IPC::Message& msg) {
135 IPC_BEGIN_MESSAGE_MAP(PPB_Buffer_Proxy, msg) 135 IPC_BEGIN_MESSAGE_MAP(PPB_Buffer_Proxy, msg)
136 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBBuffer_Create, OnMsgCreate) 136 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBBuffer_Create, OnMsgCreate)
137 IPC_END_MESSAGE_MAP() 137 IPC_END_MESSAGE_MAP()
138 // TODO(brettw) handle bad messages! 138 // TODO(brettw) handle bad messages!
139 } 139 }
140 140
141 void PPB_Buffer_Proxy::OnMsgCreate(PP_Module module, 141 void PPB_Buffer_Proxy::OnMsgCreate(PP_Module module,
142 int32_t size, 142 uint32_t size,
143 PP_Resource* result_resource, 143 PP_Resource* result_resource,
144 uint64_t* result_shm_handle) { 144 int* result_shm_handle) {
145 *result_resource = ppb_buffer_target()->Create(module, size); 145 *result_resource = ppb_buffer_target()->Create(module, size);
146 // TODO(brettw) set the shm handle from a trusted interface. 146 // TODO(brettw) set the shm handle from a trusted interface.
147 *result_shm_handle = 0; 147 *result_shm_handle = 0;
148 } 148 }
149 149
150 } // namespace proxy 150 } // namespace proxy
151 } // namespace pp 151 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_buffer_proxy.h ('k') | ppapi/proxy/ppb_image_data_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698