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

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

Issue 6282007: First pass at making the proxy handle multiple renderers. This associates the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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
« no previous file with comments | « ppapi/proxy/ppb_flash_proxy.h ('k') | ppapi/proxy/ppb_font_proxy.cc » ('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) 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_flash_proxy.h" 5 #include "ppapi/proxy/ppb_flash_proxy.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #include "ppapi/c/dev/pp_file_info_dev.h" 9 #include "ppapi/c/dev/pp_file_info_dev.h"
10 #include "ppapi/c/dev/ppb_font_dev.h" 10 #include "ppapi/c/dev/ppb_font_dev.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 return result; 42 return result;
43 */ 43 */
44 NOTIMPLEMENTED(); 44 NOTIMPLEMENTED();
45 *error = PP_ERROR_NOACCESS; 45 *error = PP_ERROR_NOACCESS;
46 return INVALID_HANDLE_VALUE; 46 return INVALID_HANDLE_VALUE;
47 #elif defined(OS_POSIX) 47 #elif defined(OS_POSIX)
48 return base::FileDescriptor(file, true); 48 return base::FileDescriptor(file, true);
49 #endif 49 #endif
50 } 50 }
51 51
52 void SetInstanceAlwaysOnTop(PP_Instance pp_instance, bool on_top) { 52 void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) {
53 PluginDispatcher::Get()->Send( 53 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(pp_instance);
54 new PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop( 54 if (dispatcher) {
55 INTERFACE_ID_PPB_FLASH, pp_instance, on_top)); 55 dispatcher->Send(new PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop(
56 INTERFACE_ID_PPB_FLASH, pp_instance, on_top));
57 }
56 } 58 }
57 59
58 bool DrawGlyphs(PP_Instance instance, 60 PP_Bool DrawGlyphs(PP_Instance instance,
59 PP_Resource pp_image_data, 61 PP_Resource pp_image_data,
60 const PP_FontDescription_Dev* font_desc, 62 const PP_FontDescription_Dev* font_desc,
61 uint32_t color, 63 uint32_t color,
62 PP_Point position, 64 PP_Point position,
63 PP_Rect clip, 65 PP_Rect clip,
64 const float transformation[3][3], 66 const float transformation[3][3],
65 uint32_t glyph_count, 67 uint32_t glyph_count,
66 const uint16_t glyph_indices[], 68 const uint16_t glyph_indices[],
67 const PP_Point glyph_advances[]) { 69 const PP_Point glyph_advances[]) {
68 Dispatcher* dispatcher = PluginDispatcher::Get(); 70 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
71 if (!dispatcher)
72 return PP_FALSE;
69 73
70 PPBFlash_DrawGlyphs_Params params; 74 PPBFlash_DrawGlyphs_Params params;
71 params.instance = instance, 75 params.instance = instance,
72 params.pp_image_data = pp_image_data; 76 params.pp_image_data = pp_image_data;
73 params.font_desc.SetFromPPFontDescription(dispatcher, *font_desc, true); 77 params.font_desc.SetFromPPFontDescription(dispatcher, *font_desc, true);
74 params.color = color; 78 params.color = color;
75 params.position = position; 79 params.position = position;
76 params.clip = clip; 80 params.clip = clip;
77 for (int i = 0; i < 3; i++) { 81 for (int i = 0; i < 3; i++) {
78 for (int j = 0; j < 3; j++) 82 for (int j = 0; j < 3; j++)
79 params.transformation[i][j] = transformation[i][j]; 83 params.transformation[i][j] = transformation[i][j];
80 } 84 }
81 85
82 params.glyph_indices.insert(params.glyph_indices.begin(), 86 params.glyph_indices.insert(params.glyph_indices.begin(),
83 &glyph_indices[0], 87 &glyph_indices[0],
84 &glyph_indices[glyph_count]); 88 &glyph_indices[glyph_count]);
85 params.glyph_advances.insert(params.glyph_advances.begin(), 89 params.glyph_advances.insert(params.glyph_advances.begin(),
86 &glyph_advances[0], 90 &glyph_advances[0],
87 &glyph_advances[glyph_count]); 91 &glyph_advances[glyph_count]);
88 92
89 bool result = false; 93 PP_Bool result = PP_FALSE;
90 dispatcher->Send(new PpapiHostMsg_PPBFlash_DrawGlyphs( 94 dispatcher->Send(new PpapiHostMsg_PPBFlash_DrawGlyphs(
91 INTERFACE_ID_PPB_FLASH, params, &result)); 95 INTERFACE_ID_PPB_FLASH, params, &result));
92 return result; 96 return result;
93 } 97 }
94 98
95 PP_Var GetProxyForURL(PP_Instance instance, const char* url) { 99 PP_Var GetProxyForURL(PP_Instance instance, const char* url) {
100 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
101 if (!dispatcher)
102 return PP_MakeUndefined();
103
96 ReceiveSerializedVarReturnValue result; 104 ReceiveSerializedVarReturnValue result;
97 PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL( 105 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL(
98 INTERFACE_ID_PPB_FLASH, instance, url, &result)); 106 INTERFACE_ID_PPB_FLASH, instance, url, &result));
99 return result.Return(PluginDispatcher::Get()); 107 return result.Return(dispatcher);
100 } 108 }
101 109
102 int32_t OpenModuleLocalFile(PP_Instance instance, 110 int32_t OpenModuleLocalFile(PP_Instance instance,
103 const char* path, 111 const char* path,
104 int32_t mode, 112 int32_t mode,
105 PP_FileHandle* file) { 113 PP_FileHandle* file) {
114 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
115 if (!dispatcher)
116 return PP_ERROR_BADARGUMENT;
117
106 int32_t result = PP_ERROR_FAILED; 118 int32_t result = PP_ERROR_FAILED;
107 IPC::PlatformFileForTransit transit; 119 IPC::PlatformFileForTransit transit;
108 PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBFlash_OpenModuleLocalFile( 120 dispatcher->Send(new PpapiHostMsg_PPBFlash_OpenModuleLocalFile(
109 INTERFACE_ID_PPB_FLASH, instance, path, mode, &transit, &result)); 121 INTERFACE_ID_PPB_FLASH, instance, path, mode, &transit, &result));
110 *file = IPC::PlatformFileForTransitToPlatformFile(transit); 122 *file = IPC::PlatformFileForTransitToPlatformFile(transit);
111 return result; 123 return result;
112 } 124 }
113 125
114 int32_t RenameModuleLocalFile(PP_Instance instance, 126 int32_t RenameModuleLocalFile(PP_Instance instance,
115 const char* path_from, 127 const char* path_from,
116 const char* path_to) { 128 const char* path_to) {
129 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
130 if (!dispatcher)
131 return PP_ERROR_BADARGUMENT;
132
117 int32_t result = PP_ERROR_FAILED; 133 int32_t result = PP_ERROR_FAILED;
118 PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBFlash_RenameModuleLocalFile( 134 dispatcher->Send(new PpapiHostMsg_PPBFlash_RenameModuleLocalFile(
119 INTERFACE_ID_PPB_FLASH, instance, path_from, path_to, &result)); 135 INTERFACE_ID_PPB_FLASH, instance, path_from, path_to, &result));
120 return result; 136 return result;
121 } 137 }
122 138
123 int32_t DeleteModuleLocalFileOrDir(PP_Instance instance, 139 int32_t DeleteModuleLocalFileOrDir(PP_Instance instance,
124 const char* path, 140 const char* path,
125 bool recursive) { 141 PP_Bool recursive) {
142 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
143 if (!dispatcher)
144 return PP_ERROR_BADARGUMENT;
145
126 int32_t result = PP_ERROR_FAILED; 146 int32_t result = PP_ERROR_FAILED;
127 PluginDispatcher::Get()->Send( 147 dispatcher->Send(new PpapiHostMsg_PPBFlash_DeleteModuleLocalFileOrDir(
128 new PpapiHostMsg_PPBFlash_DeleteModuleLocalFileOrDir( 148 INTERFACE_ID_PPB_FLASH, instance, path, recursive, &result));
129 INTERFACE_ID_PPB_FLASH, instance, path, recursive, &result));
130 return result; 149 return result;
131 } 150 }
132 151
133 int32_t CreateModuleLocalDir(PP_Instance instance, const char* path) { 152 int32_t CreateModuleLocalDir(PP_Instance instance, const char* path) {
153 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
154 if (!dispatcher)
155 return PP_ERROR_BADARGUMENT;
156
134 int32_t result = PP_ERROR_FAILED; 157 int32_t result = PP_ERROR_FAILED;
135 PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBFlash_CreateModuleLocalDir( 158 dispatcher->Send(new PpapiHostMsg_PPBFlash_CreateModuleLocalDir(
136 INTERFACE_ID_PPB_FLASH, instance, path, &result)); 159 INTERFACE_ID_PPB_FLASH, instance, path, &result));
137 return result; 160 return result;
138 } 161 }
139 162
140 int32_t QueryModuleLocalFile(PP_Instance instance, 163 int32_t QueryModuleLocalFile(PP_Instance instance,
141 const char* path, 164 const char* path,
142 PP_FileInfo_Dev* info) { 165 PP_FileInfo_Dev* info) {
166 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
167 if (!dispatcher)
168 return PP_ERROR_BADARGUMENT;
169
143 int32_t result = PP_ERROR_FAILED; 170 int32_t result = PP_ERROR_FAILED;
144 PluginDispatcher::Get()->Send( 171 dispatcher->Send(new PpapiHostMsg_PPBFlash_QueryModuleLocalFile(
145 new PpapiHostMsg_PPBFlash_QueryModuleLocalFile( 172 INTERFACE_ID_PPB_FLASH, instance, path, info, &result));
146 INTERFACE_ID_PPB_FLASH, instance, path, info, &result));
147 return result; 173 return result;
148 } 174 }
149 175
150 int32_t GetModuleLocalDirContents(PP_Instance instance, 176 int32_t GetModuleLocalDirContents(PP_Instance instance,
151 const char* path, 177 const char* path,
152 PP_DirContents_Dev** contents) { 178 PP_DirContents_Dev** contents) {
179 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
180 if (!dispatcher)
181 return PP_ERROR_BADARGUMENT;
182
153 int32_t result = PP_ERROR_FAILED; 183 int32_t result = PP_ERROR_FAILED;
154 std::vector<SerializedDirEntry> entries; 184 std::vector<SerializedDirEntry> entries;
155 PluginDispatcher::Get()->Send( 185 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetModuleLocalDirContents(
156 new PpapiHostMsg_PPBFlash_GetModuleLocalDirContents( 186 INTERFACE_ID_PPB_FLASH, instance, path, &entries, &result));
157 INTERFACE_ID_PPB_FLASH, instance, path, &entries, &result));
158 187
159 if (result != PP_OK) 188 if (result != PP_OK)
160 return result; 189 return result;
161 190
162 // Copy the serialized dir entries to the output struct. 191 // Copy the serialized dir entries to the output struct.
163 *contents = new PP_DirContents_Dev; 192 *contents = new PP_DirContents_Dev;
164 (*contents)->count = static_cast<int32_t>(entries.size()); 193 (*contents)->count = static_cast<int32_t>(entries.size());
165 (*contents)->entries = new PP_DirEntry_Dev[entries.size()]; 194 (*contents)->entries = new PP_DirEntry_Dev[entries.size()];
166 for (size_t i = 0; i < entries.size(); i++) { 195 for (size_t i = 0; i < entries.size(); i++) {
167 const SerializedDirEntry& source = entries[i]; 196 const SerializedDirEntry& source = entries[i];
168 PP_DirEntry_Dev* dest = &(*contents)->entries[i]; 197 PP_DirEntry_Dev* dest = &(*contents)->entries[i];
169 198
170 char* name_copy = new char[source.name.size() + 1]; 199 char* name_copy = new char[source.name.size() + 1];
171 memcpy(name_copy, source.name.c_str(), source.name.size() + 1); 200 memcpy(name_copy, source.name.c_str(), source.name.size() + 1);
172 dest->name = name_copy; 201 dest->name = name_copy;
173 dest->is_dir = source.is_dir; 202 dest->is_dir = BoolToPPBool(source.is_dir);
174 } 203 }
175 204
176 return result; 205 return result;
177 } 206 }
178 207
179 void FreeModuleLocalDirContents(PP_Instance instance, 208 void FreeModuleLocalDirContents(PP_Instance /* instance */,
180 PP_DirContents_Dev* contents) { 209 PP_DirContents_Dev* contents) {
181 for (int32_t i = 0; i < contents->count; ++i) 210 for (int32_t i = 0; i < contents->count; ++i)
182 delete[] contents->entries[i].name; 211 delete[] contents->entries[i].name;
183 delete[] contents->entries; 212 delete[] contents->entries;
184 delete contents; 213 delete contents;
185 } 214 }
186 215
187 bool NavigateToURL(PP_Instance pp_instance, 216 PP_Bool NavigateToURL(PP_Instance instance,
188 const char* url, 217 const char* url,
189 const char* target) { 218 const char* target) {
190 bool result = false; 219 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
191 PluginDispatcher::Get()->Send( 220 if (!dispatcher)
192 new PpapiHostMsg_PPBFlash_NavigateToURL( 221 return PP_FALSE;
193 INTERFACE_ID_PPB_FLASH, pp_instance, url, target, &result)); 222
223 PP_Bool result = PP_FALSE;
224 dispatcher->Send(new PpapiHostMsg_PPBFlash_NavigateToURL(
225 INTERFACE_ID_PPB_FLASH, instance, url, target, &result));
194 return result; 226 return result;
195 } 227 }
196 228
197 const PPB_Flash ppb_flash = { 229 const PPB_Flash ppb_flash = {
198 &SetInstanceAlwaysOnTop, 230 &SetInstanceAlwaysOnTop,
199 &DrawGlyphs, 231 &DrawGlyphs,
200 &GetProxyForURL, 232 &GetProxyForURL,
201 &OpenModuleLocalFile, 233 &OpenModuleLocalFile,
202 &RenameModuleLocalFile, 234 &RenameModuleLocalFile,
203 &DeleteModuleLocalFileOrDir, 235 &DeleteModuleLocalFileOrDir,
204 &CreateModuleLocalDir, 236 &CreateModuleLocalDir,
205 &QueryModuleLocalFile, 237 &QueryModuleLocalFile,
206 &GetModuleLocalDirContents, 238 &GetModuleLocalDirContents,
207 &FreeModuleLocalDirContents, 239 &FreeModuleLocalDirContents,
208 &NavigateToURL, 240 &NavigateToURL,
209 }; 241 };
210 242
211 } // namespace 243 } // namespace
212 244
213 PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher, 245 PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher,
214 const void* target_interface) 246 const void* target_interface)
215 : InterfaceProxy(dispatcher, target_interface) { 247 : InterfaceProxy(dispatcher, target_interface) {
216 } 248 }
217 249
218 PPB_Flash_Proxy::~PPB_Flash_Proxy() { 250 PPB_Flash_Proxy::~PPB_Flash_Proxy() {
219 } 251 }
220 252
221 const void* PPB_Flash_Proxy::GetSourceInterface() const { 253 const void* PPB_Flash_Proxy::GetSourceInterface() const {
222 return &ppb_flash; 254 return &ppb_flash;
223 } 255 }
224 256
(...skipping 24 matching lines...) Expand all
249 OnMsgGetModuleLocalDirContents) 281 OnMsgGetModuleLocalDirContents)
250 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_NavigateToURL, OnMsgNavigateToURL) 282 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_NavigateToURL, OnMsgNavigateToURL)
251 IPC_MESSAGE_UNHANDLED(handled = false) 283 IPC_MESSAGE_UNHANDLED(handled = false)
252 IPC_END_MESSAGE_MAP() 284 IPC_END_MESSAGE_MAP()
253 // TODO(brettw) handle bad messages! 285 // TODO(brettw) handle bad messages!
254 return handled; 286 return handled;
255 } 287 }
256 288
257 void PPB_Flash_Proxy::OnMsgSetInstanceAlwaysOnTop( 289 void PPB_Flash_Proxy::OnMsgSetInstanceAlwaysOnTop(
258 PP_Instance instance, 290 PP_Instance instance,
259 bool on_top) { 291 PP_Bool on_top) {
260 ppb_flash_target()->SetInstanceAlwaysOnTop(instance, on_top); 292 ppb_flash_target()->SetInstanceAlwaysOnTop(instance, on_top);
261 } 293 }
262 294
263 void PPB_Flash_Proxy::OnMsgDrawGlyphs( 295 void PPB_Flash_Proxy::OnMsgDrawGlyphs(
264 const pp::proxy::PPBFlash_DrawGlyphs_Params& params, 296 const pp::proxy::PPBFlash_DrawGlyphs_Params& params,
265 bool* result) { 297 PP_Bool* result) {
266 *result = false; 298 *result = PP_FALSE;
267 299
268 PP_FontDescription_Dev font_desc; 300 PP_FontDescription_Dev font_desc;
269 params.font_desc.SetToPPFontDescription(dispatcher(), &font_desc, false); 301 params.font_desc.SetToPPFontDescription(dispatcher(), &font_desc, false);
270 302
271 if (params.glyph_indices.size() != params.glyph_advances.size() || 303 if (params.glyph_indices.size() != params.glyph_advances.size() ||
272 params.glyph_indices.empty()) 304 params.glyph_indices.empty())
273 return; 305 return;
274 306
275 *result = ppb_flash_target()->DrawGlyphs( 307 *result = ppb_flash_target()->DrawGlyphs(
276 params.instance, params.pp_image_data, &font_desc, params.color, 308 params.instance, params.pp_image_data, &font_desc, params.color,
(...skipping 29 matching lines...) Expand all
306 const std::string& path_to, 338 const std::string& path_to,
307 int32_t* result) { 339 int32_t* result) {
308 *result = ppb_flash_target()->RenameModuleLocalFile(instance, 340 *result = ppb_flash_target()->RenameModuleLocalFile(instance,
309 path_from.c_str(), 341 path_from.c_str(),
310 path_to.c_str()); 342 path_to.c_str());
311 } 343 }
312 344
313 void PPB_Flash_Proxy::OnMsgDeleteModuleLocalFileOrDir( 345 void PPB_Flash_Proxy::OnMsgDeleteModuleLocalFileOrDir(
314 PP_Instance instance, 346 PP_Instance instance,
315 const std::string& path, 347 const std::string& path,
316 bool recursive, 348 PP_Bool recursive,
317 int32_t* result) { 349 int32_t* result) {
318 *result = ppb_flash_target()->DeleteModuleLocalFileOrDir(instance, 350 *result = ppb_flash_target()->DeleteModuleLocalFileOrDir(instance,
319 path.c_str(), 351 path.c_str(),
320 recursive); 352 recursive);
321 } 353 }
322 354
323 void PPB_Flash_Proxy::OnMsgCreateModuleLocalDir(PP_Instance instance, 355 void PPB_Flash_Proxy::OnMsgCreateModuleLocalDir(PP_Instance instance,
324 const std::string& path, 356 const std::string& path,
325 int32_t* result) { 357 int32_t* result) {
326 *result = ppb_flash_target()->CreateModuleLocalDir(instance, path.c_str()); 358 *result = ppb_flash_target()->CreateModuleLocalDir(instance, path.c_str());
(...skipping 24 matching lines...) Expand all
351 for (int32_t i = 0; i < contents->count; i++) { 383 for (int32_t i = 0; i < contents->count; i++) {
352 (*entries)[i].name.assign(contents->entries[i].name); 384 (*entries)[i].name.assign(contents->entries[i].name);
353 (*entries)[i].is_dir = contents->entries[i].is_dir; 385 (*entries)[i].is_dir = contents->entries[i].is_dir;
354 } 386 }
355 ppb_flash_target()->FreeModuleLocalDirContents(instance, contents); 387 ppb_flash_target()->FreeModuleLocalDirContents(instance, contents);
356 } 388 }
357 389
358 void PPB_Flash_Proxy::OnMsgNavigateToURL(PP_Instance instance, 390 void PPB_Flash_Proxy::OnMsgNavigateToURL(PP_Instance instance,
359 const std::string& url, 391 const std::string& url,
360 const std::string& target, 392 const std::string& target,
361 bool* result) { 393 PP_Bool* result) {
362 *result = ppb_flash_target()->NavigateToURL(instance, url.c_str(), 394 *result = ppb_flash_target()->NavigateToURL(instance, url.c_str(),
363 target.c_str()); 395 target.c_str());
364 } 396 }
365 397
366 } // namespace proxy 398 } // namespace proxy
367 } // namespace pp 399 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_flash_proxy.h ('k') | ppapi/proxy/ppb_font_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698