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

Side by Side Diff: ppapi/thunk/enter.h

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/shared_impl/video_decoder_impl.cc ('k') | webkit/glue/webkit_glue.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Deleted: svn:mergeinfo
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 #ifndef PPAPI_THUNK_ENTER_H_ 5 #ifndef PPAPI_THUNK_ENTER_H_
6 #define PPAPI_THUNK_ENTER_H_ 6 #define PPAPI_THUNK_ENTER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "ppapi/c/pp_resource.h" 9 #include "ppapi/c/pp_resource.h"
10 #include "ppapi/proxy/interface_id.h" 10 #include "ppapi/proxy/interface_id.h"
11 #include "ppapi/shared_impl/function_group_base.h" 11 #include "ppapi/shared_impl/function_group_base.h"
12 #include "ppapi/shared_impl/ppapi_globals.h"
12 #include "ppapi/shared_impl/proxy_lock.h" 13 #include "ppapi/shared_impl/proxy_lock.h"
13 #include "ppapi/shared_impl/resource.h" 14 #include "ppapi/shared_impl/resource.h"
15 #include "ppapi/shared_impl/resource_tracker.h"
14 #include "ppapi/shared_impl/tracker_base.h" 16 #include "ppapi/shared_impl/tracker_base.h"
15 #include "ppapi/shared_impl/resource_tracker.h"
16 #include "ppapi/thunk/ppapi_thunk_export.h" 17 #include "ppapi/thunk/ppapi_thunk_export.h"
17 #include "ppapi/thunk/ppb_instance_api.h" 18 #include "ppapi/thunk/ppb_instance_api.h"
18 #include "ppapi/thunk/resource_creation_api.h" 19 #include "ppapi/thunk/resource_creation_api.h"
19 20
20 namespace ppapi { 21 namespace ppapi {
21 namespace thunk { 22 namespace thunk {
22 23
23 // Enter* helper objects: These objects wrap a call from the C PPAPI into 24 // Enter* helper objects: These objects wrap a call from the C PPAPI into
24 // the internal implementation. They make sure the lock is acquired and will 25 // the internal implementation. They make sure the lock is acquired and will
25 // automatically set up some stuff for you. 26 // automatically set up some stuff for you.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 class EnterFunctionGivenResource : public EnterFunction<FunctionsT> { 110 class EnterFunctionGivenResource : public EnterFunction<FunctionsT> {
110 public: 111 public:
111 EnterFunctionGivenResource(PP_Resource resource, bool report_error) 112 EnterFunctionGivenResource(PP_Resource resource, bool report_error)
112 : EnterFunction<FunctionsT>(GetInstanceForResource(resource), 113 : EnterFunction<FunctionsT>(GetInstanceForResource(resource),
113 report_error) { 114 report_error) {
114 } 115 }
115 116
116 private: 117 private:
117 static PP_Instance GetInstanceForResource(PP_Resource resource) { 118 static PP_Instance GetInstanceForResource(PP_Resource resource) {
118 Resource* object = 119 Resource* object =
119 TrackerBase::Get()->GetResourceTracker()->GetResource(resource); 120 PpapiGlobals::Get()->GetResourceTracker()->GetResource(resource);
120 return object ? object->pp_instance() : 0; 121 return object ? object->pp_instance() : 0;
121 } 122 }
122 }; 123 };
123 124
124 // EnterResource --------------------------------------------------------------- 125 // EnterResource ---------------------------------------------------------------
125 126
126 template<typename ResourceT, bool lock_on_entry = true> 127 template<typename ResourceT, bool lock_on_entry = true>
127 class EnterResource : subtle::LockOnEntry<lock_on_entry> { 128 class EnterResource : subtle::LockOnEntry<lock_on_entry> {
128 public: 129 public:
129 EnterResource(PP_Resource resource, bool report_error) 130 EnterResource(PP_Resource resource, bool report_error)
130 : object_(NULL) { 131 : object_(NULL) {
131 resource_ = TrackerBase::Get()->GetResourceTracker()->GetResource(resource); 132 resource_ =
133 PpapiGlobals::Get()->GetResourceTracker()->GetResource(resource);
132 if (resource_) 134 if (resource_)
133 object_ = resource_->GetAs<ResourceT>(); 135 object_ = resource_->GetAs<ResourceT>();
134 // TODO(brettw) check error and if report_error is set, do something. 136 // TODO(brettw) check error and if report_error is set, do something.
135 } 137 }
136 ~EnterResource() {} 138 ~EnterResource() {}
137 139
138 bool succeeded() const { return !!object_; } 140 bool succeeded() const { return !!object_; }
139 bool failed() const { return !object_; } 141 bool failed() const { return !object_; }
140 142
141 ResourceT* object() { return object_; } 143 ResourceT* object() { return object_; }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 : public EnterFunctionNoLock<PPB_Instance_FunctionAPI> { 176 : public EnterFunctionNoLock<PPB_Instance_FunctionAPI> {
175 public: 177 public:
176 EnterInstance(PP_Instance instance); 178 EnterInstance(PP_Instance instance);
177 ~EnterInstance(); 179 ~EnterInstance();
178 }; 180 };
179 181
180 } // namespace thunk 182 } // namespace thunk
181 } // namespace ppapi 183 } // namespace ppapi
182 184
183 #endif // PPAPI_THUNK_ENTER_H_ 185 #endif // PPAPI_THUNK_ENTER_H_
OLDNEW
« no previous file with comments | « ppapi/shared_impl/video_decoder_impl.cc ('k') | webkit/glue/webkit_glue.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698