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

Side by Side Diff: webkit/plugins/ppapi/host_globals.cc

Issue 9034035: Make it possible to have 1 PpapiGlobals per thread. Update unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments. Created 8 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 | « webkit/plugins/ppapi/host_globals.h ('k') | no next file » | 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 "webkit/plugins/ppapi/host_globals.h" 5 #include "webkit/plugins/ppapi/host_globals.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
(...skipping 27 matching lines...) Expand all
38 function_proxies[::ppapi::API_ID_COUNT]; 38 function_proxies[::ppapi::API_ID_COUNT];
39 }; 39 };
40 40
41 HostGlobals* HostGlobals::host_globals_ = NULL; 41 HostGlobals* HostGlobals::host_globals_ = NULL;
42 42
43 HostGlobals::HostGlobals() : ::ppapi::PpapiGlobals() { 43 HostGlobals::HostGlobals() : ::ppapi::PpapiGlobals() {
44 DCHECK(!host_globals_); 44 DCHECK(!host_globals_);
45 host_globals_ = this; 45 host_globals_ = this;
46 } 46 }
47 47
48 HostGlobals::HostGlobals(::ppapi::PpapiGlobals::ForTest for_test)
49 : ::ppapi::PpapiGlobals(for_test) {
50 DCHECK(!host_globals_);
51 }
52
48 HostGlobals::~HostGlobals() { 53 HostGlobals::~HostGlobals() {
49 DCHECK(host_globals_ == this); 54 DCHECK(host_globals_ == this || !host_globals_);
50 host_globals_ = NULL; 55 host_globals_ = NULL;
51 } 56 }
52 57
53 ::ppapi::ResourceTracker* HostGlobals::GetResourceTracker() { 58 ::ppapi::ResourceTracker* HostGlobals::GetResourceTracker() {
54 return &resource_tracker_; 59 return &resource_tracker_;
55 } 60 }
56 61
57 ::ppapi::VarTracker* HostGlobals::GetVarTracker() { 62 ::ppapi::VarTracker* HostGlobals::GetVarTracker() {
58 return &host_var_tracker_; 63 return &host_var_tracker_;
59 } 64 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 return proxy.get(); 114 return proxy.get();
110 } 115 }
111 116
112 PP_Module HostGlobals::GetModuleForInstance(PP_Instance instance) { 117 PP_Module HostGlobals::GetModuleForInstance(PP_Instance instance) {
113 PluginInstance* inst = GetInstance(instance); 118 PluginInstance* inst = GetInstance(instance);
114 if (!inst) 119 if (!inst)
115 return 0; 120 return 0;
116 return inst->module()->pp_module(); 121 return inst->module()->pp_module();
117 } 122 }
118 123
124 base::Lock* HostGlobals::GetProxyLock() {
125 // We do not lock on the host side.
126 return NULL;
127 }
128
119 PP_Module HostGlobals::AddModule(PluginModule* module) { 129 PP_Module HostGlobals::AddModule(PluginModule* module) {
120 #ifndef NDEBUG 130 #ifndef NDEBUG
121 // Make sure we're not adding one more than once. 131 // Make sure we're not adding one more than once.
122 for (ModuleMap::const_iterator i = module_map_.begin(); 132 for (ModuleMap::const_iterator i = module_map_.begin();
123 i != module_map_.end(); ++i) 133 i != module_map_.end(); ++i)
124 DCHECK(i->second != module); 134 DCHECK(i->second != module);
125 #endif 135 #endif
126 136
127 // See AddInstance. 137 // See AddInstance.
128 PP_Module new_module; 138 PP_Module new_module;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 200
191 PluginInstance* HostGlobals::GetInstance(PP_Instance instance) { 201 PluginInstance* HostGlobals::GetInstance(PP_Instance instance) {
192 DLOG_IF(ERROR, !CheckIdType(instance, ::ppapi::PP_ID_TYPE_INSTANCE)) 202 DLOG_IF(ERROR, !CheckIdType(instance, ::ppapi::PP_ID_TYPE_INSTANCE))
193 << instance << " is not a PP_Instance."; 203 << instance << " is not a PP_Instance.";
194 InstanceMap::iterator found = instance_map_.find(instance); 204 InstanceMap::iterator found = instance_map_.find(instance);
195 if (found == instance_map_.end()) 205 if (found == instance_map_.end())
196 return NULL; 206 return NULL;
197 return found->second->instance; 207 return found->second->instance;
198 } 208 }
199 209
210 bool HostGlobals::IsHostGlobals() const {
211 return true;
212 }
213
200 } // namespace ppapi 214 } // namespace ppapi
201 } // namespace webkit 215 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/host_globals.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698