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

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

Issue 8826011: Remove PP_Module from parameters for PPB_Var.VarFromUtf8. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 9 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_font_proxy.cc ('k') | ppapi/proxy/ppb_var_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) 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_var_deprecated_proxy.h" 5 #include "ppapi/proxy/ppb_var_deprecated_proxy.h"
6 6
7 #include <stdlib.h> // For malloc 7 #include <stdlib.h> // For malloc
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/task.h" 12 #include "base/task.h"
13 #include "ppapi/c/dev/ppb_var_deprecated.h" 13 #include "ppapi/c/dev/ppb_var_deprecated.h"
14 #include "ppapi/c/pp_var.h" 14 #include "ppapi/c/pp_var.h"
15 #include "ppapi/c/ppb_var.h"
15 #include "ppapi/c/ppb_core.h" 16 #include "ppapi/c/ppb_core.h"
16 #include "ppapi/proxy/host_dispatcher.h" 17 #include "ppapi/proxy/host_dispatcher.h"
17 #include "ppapi/proxy/plugin_dispatcher.h" 18 #include "ppapi/proxy/plugin_dispatcher.h"
18 #include "ppapi/proxy/plugin_globals.h" 19 #include "ppapi/proxy/plugin_globals.h"
19 #include "ppapi/proxy/plugin_resource_tracker.h" 20 #include "ppapi/proxy/plugin_resource_tracker.h"
20 #include "ppapi/proxy/plugin_var_tracker.h" 21 #include "ppapi/proxy/plugin_var_tracker.h"
21 #include "ppapi/proxy/ppapi_messages.h" 22 #include "ppapi/proxy/ppapi_messages.h"
22 #include "ppapi/proxy/ppp_class_proxy.h" 23 #include "ppapi/proxy/ppp_class_proxy.h"
23 #include "ppapi/proxy/serialized_var.h" 24 #include "ppapi/proxy/serialized_var.h"
25 #include "ppapi/shared_impl/ppb_var_impl.h"
24 #include "ppapi/shared_impl/var.h" 26 #include "ppapi/shared_impl/var.h"
25 27
26 namespace ppapi { 28 namespace ppapi {
27 namespace proxy { 29 namespace proxy {
28 30
29 namespace { 31 namespace {
30 32
31 // Used to do get the set-up information for calling a var object. If the 33 // Used to do get the set-up information for calling a var object. If the
32 // exception is set, returns NULL. Otherwise, computes the dispatcher for the 34 // exception is set, returns NULL. Otherwise, computes the dispatcher for the
33 // given var object. If the var is not a valid object, returns NULL and sets 35 // given var object. If the var is not a valid object, returns NULL and sets
(...skipping 11 matching lines...) Expand all
45 PluginDispatcher* dispatcher = 47 PluginDispatcher* dispatcher =
46 PluginGlobals::Get()->plugin_var_tracker()-> 48 PluginGlobals::Get()->plugin_var_tracker()->
47 DispatcherForPluginObject(object); 49 DispatcherForPluginObject(object);
48 if (dispatcher) 50 if (dispatcher)
49 return dispatcher; 51 return dispatcher;
50 } 52 }
51 53
52 // The object is invalid. This means we can't figure out which dispatcher 54 // The object is invalid. This means we can't figure out which dispatcher
53 // to use, which is OK because the call will fail anyway. Set the exception. 55 // to use, which is OK because the call will fail anyway. Set the exception.
54 if (exception) { 56 if (exception) {
55 *exception = StringVar::StringToPPVar(0, 57 *exception = StringVar::StringToPPVar(
56 std::string("Attempting to use an invalid object")); 58 std::string("Attempting to use an invalid object"));
57 } 59 }
58 return NULL; 60 return NULL;
59 } 61 }
60 62
61 // PPB_Var_Deprecated plugin --------------------------------------------------- 63 // PPB_Var_Deprecated plugin ---------------------------------------------------
62 64
63 void AddRefVar(PP_Var var) {
64 PpapiGlobals::Get()->GetVarTracker()->AddRefVar(var);
65 }
66
67 void ReleaseVar(PP_Var var) {
68 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var);
69 }
70
71 PP_Var VarFromUtf8(PP_Module module, const char* data, uint32_t len) {
72 return StringVar::StringToPPVar(module, data, len);
73 }
74
75 const char* VarToUtf8(PP_Var var, uint32_t* len) {
76 StringVar* str = StringVar::FromPPVar(var);
77 if (str) {
78 *len = static_cast<uint32_t>(str->value().size());
79 return str->value().c_str();
80 }
81 *len = 0;
82 return NULL;
83 }
84
85 bool HasProperty(PP_Var var, 65 bool HasProperty(PP_Var var,
86 PP_Var name, 66 PP_Var name,
87 PP_Var* exception) { 67 PP_Var* exception) {
88 Dispatcher* dispatcher = CheckExceptionAndGetDispatcher(var, exception); 68 Dispatcher* dispatcher = CheckExceptionAndGetDispatcher(var, exception);
89 if (!dispatcher) 69 if (!dispatcher)
90 return false; 70 return false;
91 71
92 ReceiveSerializedException se(dispatcher, exception); 72 ReceiveSerializedException se(dispatcher, exception);
93 PP_Bool result = PP_FALSE; 73 PP_Bool result = PP_FALSE;
94 if (!se.IsThrown()) { 74 if (!se.IsThrown()) {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 ReceiveSerializedVarReturnValue result; 247 ReceiveSerializedVarReturnValue result;
268 int64 class_int = static_cast<int64>(reinterpret_cast<intptr_t>(ppp_class)); 248 int64 class_int = static_cast<int64>(reinterpret_cast<intptr_t>(ppp_class));
269 int64 data_int = 249 int64 data_int =
270 static_cast<int64>(reinterpret_cast<intptr_t>(ppp_class_data)); 250 static_cast<int64>(reinterpret_cast<intptr_t>(ppp_class_data));
271 dispatcher->Send(new PpapiHostMsg_PPBVar_CreateObjectDeprecated( 251 dispatcher->Send(new PpapiHostMsg_PPBVar_CreateObjectDeprecated(
272 API_ID_PPB_VAR_DEPRECATED, instance, class_int, data_int, 252 API_ID_PPB_VAR_DEPRECATED, instance, class_int, data_int,
273 &result)); 253 &result));
274 return result.Return(dispatcher); 254 return result.Return(dispatcher);
275 } 255 }
276 256
277 const PPB_Var_Deprecated var_deprecated_interface = {
278 &AddRefVar,
279 &ReleaseVar,
280 &VarFromUtf8,
281 &VarToUtf8,
282 &HasProperty,
283 &HasMethod,
284 &GetProperty,
285 &EnumerateProperties,
286 &SetProperty,
287 &RemoveProperty,
288 &Call,
289 &Construct,
290 &IsInstanceOf,
291 &CreateObject
292 };
293
294 InterfaceProxy* CreateVarDeprecatedProxy(Dispatcher* dispatcher) { 257 InterfaceProxy* CreateVarDeprecatedProxy(Dispatcher* dispatcher) {
295 return new PPB_Var_Deprecated_Proxy(dispatcher ); 258 return new PPB_Var_Deprecated_Proxy(dispatcher );
296 } 259 }
297 260
298 } // namespace 261 } // namespace
299 262
300 PPB_Var_Deprecated_Proxy::PPB_Var_Deprecated_Proxy( 263 PPB_Var_Deprecated_Proxy::PPB_Var_Deprecated_Proxy(
301 Dispatcher* dispatcher) 264 Dispatcher* dispatcher)
302 : InterfaceProxy(dispatcher), 265 : InterfaceProxy(dispatcher),
303 task_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 266 task_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
304 ppb_var_impl_(NULL) { 267 ppb_var_impl_(NULL) {
305 if (!dispatcher->IsPlugin()) { 268 if (!dispatcher->IsPlugin()) {
306 ppb_var_impl_ = static_cast<const PPB_Var_Deprecated*>( 269 ppb_var_impl_ = static_cast<const PPB_Var_Deprecated*>(
307 dispatcher->local_get_interface()(PPB_VAR_DEPRECATED_INTERFACE)); 270 dispatcher->local_get_interface()(PPB_VAR_DEPRECATED_INTERFACE));
308 } 271 }
309 } 272 }
310 273
311 PPB_Var_Deprecated_Proxy::~PPB_Var_Deprecated_Proxy() { 274 PPB_Var_Deprecated_Proxy::~PPB_Var_Deprecated_Proxy() {
312 } 275 }
313 276
314 // static 277 // static
315 const InterfaceProxy::Info* PPB_Var_Deprecated_Proxy::GetInfo() { 278 const InterfaceProxy::Info* PPB_Var_Deprecated_Proxy::GetInfo() {
279 static const PPB_Var_Deprecated var_deprecated_interface = {
280 ppapi::PPB_Var_Impl::GetVarInterface1_0()->AddRef,
281 ppapi::PPB_Var_Impl::GetVarInterface1_0()->Release,
282 ppapi::PPB_Var_Impl::GetVarInterface1_0()->VarFromUtf8,
283 ppapi::PPB_Var_Impl::GetVarInterface1_0()->VarToUtf8,
284 &HasProperty,
285 &HasMethod,
286 &GetProperty,
287 &EnumerateProperties,
288 &SetProperty,
289 &RemoveProperty,
290 &Call,
291 &Construct,
292 &IsInstanceOf,
293 &CreateObject
294 };
295
316 static const Info info = { 296 static const Info info = {
317 &var_deprecated_interface, 297 &var_deprecated_interface,
318 PPB_VAR_DEPRECATED_INTERFACE, 298 PPB_VAR_DEPRECATED_INTERFACE,
319 API_ID_PPB_VAR_DEPRECATED, 299 API_ID_PPB_VAR_DEPRECATED,
320 false, 300 false,
321 &CreateVarDeprecatedProxy, 301 &CreateVarDeprecatedProxy,
322 }; 302 };
323 return &info; 303 return &info;
324 } 304 }
325 305
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 505
526 void PPB_Var_Deprecated_Proxy::DoReleaseObject(int64 object_id) { 506 void PPB_Var_Deprecated_Proxy::DoReleaseObject(int64 object_id) {
527 PP_Var var; 507 PP_Var var;
528 var.type = PP_VARTYPE_OBJECT; 508 var.type = PP_VARTYPE_OBJECT;
529 var.value.as_id = object_id; 509 var.value.as_id = object_id;
530 ppb_var_impl_->Release(var); 510 ppb_var_impl_->Release(var);
531 } 511 }
532 512
533 } // namespace proxy 513 } // namespace proxy
534 } // namespace ppapi 514 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_font_proxy.cc ('k') | ppapi/proxy/ppb_var_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698