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

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

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