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

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

Issue 8344025: Add a new globals object for PPAPI tracking information. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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_url_loader_proxy.cc ('k') | ppapi/proxy/ppb_var_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_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_core.h" 15 #include "ppapi/c/ppb_core.h"
16 #include "ppapi/proxy/host_dispatcher.h" 16 #include "ppapi/proxy/host_dispatcher.h"
17 #include "ppapi/proxy/plugin_dispatcher.h" 17 #include "ppapi/proxy/plugin_dispatcher.h"
18 #include "ppapi/proxy/plugin_globals.h"
18 #include "ppapi/proxy/plugin_resource_tracker.h" 19 #include "ppapi/proxy/plugin_resource_tracker.h"
19 #include "ppapi/proxy/plugin_var_tracker.h" 20 #include "ppapi/proxy/plugin_var_tracker.h"
20 #include "ppapi/proxy/ppapi_messages.h" 21 #include "ppapi/proxy/ppapi_messages.h"
21 #include "ppapi/proxy/ppp_class_proxy.h" 22 #include "ppapi/proxy/ppp_class_proxy.h"
22 #include "ppapi/proxy/serialized_var.h" 23 #include "ppapi/proxy/serialized_var.h"
23 #include "ppapi/shared_impl/var.h" 24 #include "ppapi/shared_impl/var.h"
24 25
25 namespace ppapi { 26 namespace ppapi {
26 namespace proxy { 27 namespace proxy {
27 28
28 namespace { 29 namespace {
29 30
30 // Used to do get the set-up information for calling a var object. If the 31 // Used to do get the set-up information for calling a var object. If the
31 // exception is set, returns NULL. Otherwise, computes the dispatcher for the 32 // exception is set, returns NULL. Otherwise, computes the dispatcher for the
32 // given var object. If the var is not a valid object, returns NULL and sets 33 // given var object. If the var is not a valid object, returns NULL and sets
33 // the exception. 34 // the exception.
34 PluginDispatcher* CheckExceptionAndGetDispatcher(const PP_Var& object, 35 PluginDispatcher* CheckExceptionAndGetDispatcher(const PP_Var& object,
35 PP_Var* exception) { 36 PP_Var* exception) {
36 // If an exception is already set, we don't need to do anything, just return 37 // If an exception is already set, we don't need to do anything, just return
37 // an error to the caller. 38 // an error to the caller.
38 if (exception && exception->type != PP_VARTYPE_UNDEFINED) 39 if (exception && exception->type != PP_VARTYPE_UNDEFINED)
39 return NULL; 40 return NULL;
40 41
41 42
42 if (object.type == PP_VARTYPE_OBJECT) { 43 if (object.type == PP_VARTYPE_OBJECT) {
43 // Get the dispatcher for the object. 44 // Get the dispatcher for the object.
44 PluginDispatcher* dispatcher = PluginResourceTracker::GetInstance()-> 45 PluginDispatcher* dispatcher =
45 var_tracker().DispatcherForPluginObject(object); 46 PluginGlobals::Get()->plugin_var_tracker()->
47 DispatcherForPluginObject(object);
46 if (dispatcher) 48 if (dispatcher)
47 return dispatcher; 49 return dispatcher;
48 } 50 }
49 51
50 // The object is invalid. This means we can't figure out which dispatcher 52 // The object is invalid. This means we can't figure out which dispatcher
51 // to use, which is OK because the call will fail anyway. Set the exception. 53 // to use, which is OK because the call will fail anyway. Set the exception.
52 if (exception) { 54 if (exception) {
53 *exception = StringVar::StringToPPVar(0, 55 *exception = StringVar::StringToPPVar(0,
54 std::string("Attempting to use an invalid object")); 56 std::string("Attempting to use an invalid object"));
55 } 57 }
56 return NULL; 58 return NULL;
57 } 59 }
58 60
59 // PPB_Var_Deprecated plugin --------------------------------------------------- 61 // PPB_Var_Deprecated plugin ---------------------------------------------------
60 62
61 void AddRefVar(PP_Var var) { 63 void AddRefVar(PP_Var var) {
62 PluginResourceTracker::GetInstance()->var_tracker().AddRefVar(var); 64 PpapiGlobals::Get()->GetVarTracker()->AddRefVar(var);
63 } 65 }
64 66
65 void ReleaseVar(PP_Var var) { 67 void ReleaseVar(PP_Var var) {
66 PluginResourceTracker::GetInstance()->var_tracker().ReleaseVar(var); 68 PpapiGlobals::Get()->GetVarTracker()->ReleaseVar(var);
67 } 69 }
68 70
69 PP_Var VarFromUtf8(PP_Module module, const char* data, uint32_t len) { 71 PP_Var VarFromUtf8(PP_Module module, const char* data, uint32_t len) {
70 return StringVar::StringToPPVar(module, data, len); 72 return StringVar::StringToPPVar(module, data, len);
71 } 73 }
72 74
73 const char* VarToUtf8(PP_Var var, uint32_t* len) { 75 const char* VarToUtf8(PP_Var var, uint32_t* len) {
74 StringVar* str = StringVar::FromPPVar(var); 76 StringVar* str = StringVar::FromPPVar(var);
75 if (str) { 77 if (str) {
76 *len = static_cast<uint32_t>(str->value().size()); 78 *len = static_cast<uint32_t>(str->value().size());
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 521
520 void PPB_Var_Deprecated_Proxy::DoReleaseObject(int64 object_id) { 522 void PPB_Var_Deprecated_Proxy::DoReleaseObject(int64 object_id) {
521 PP_Var var; 523 PP_Var var;
522 var.type = PP_VARTYPE_OBJECT; 524 var.type = PP_VARTYPE_OBJECT;
523 var.value.as_id = object_id; 525 var.value.as_id = object_id;
524 ppb_var_impl_->Release(var); 526 ppb_var_impl_->Release(var);
525 } 527 }
526 528
527 } // namespace proxy 529 } // namespace proxy
528 } // namespace ppapi 530 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_url_loader_proxy.cc ('k') | ppapi/proxy/ppb_var_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698