| OLD | NEW |
| 1 // Copyright (c) 2012 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" |
| 11 #include "ppapi/shared_impl/api_id.h" | 11 #include "ppapi/shared_impl/api_id.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 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 | |
| 53 HostGlobals::~HostGlobals() { | 48 HostGlobals::~HostGlobals() { |
| 54 DCHECK(host_globals_ == this || !host_globals_); | 49 DCHECK(host_globals_ == this); |
| 55 host_globals_ = NULL; | 50 host_globals_ = NULL; |
| 56 } | 51 } |
| 57 | 52 |
| 58 ::ppapi::ResourceTracker* HostGlobals::GetResourceTracker() { | 53 ::ppapi::ResourceTracker* HostGlobals::GetResourceTracker() { |
| 59 return &resource_tracker_; | 54 return &resource_tracker_; |
| 60 } | 55 } |
| 61 | 56 |
| 62 ::ppapi::VarTracker* HostGlobals::GetVarTracker() { | 57 ::ppapi::VarTracker* HostGlobals::GetVarTracker() { |
| 63 return &host_var_tracker_; | 58 return &host_var_tracker_; |
| 64 } | 59 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 return proxy.get(); | 109 return proxy.get(); |
| 115 } | 110 } |
| 116 | 111 |
| 117 PP_Module HostGlobals::GetModuleForInstance(PP_Instance instance) { | 112 PP_Module HostGlobals::GetModuleForInstance(PP_Instance instance) { |
| 118 PluginInstance* inst = GetInstance(instance); | 113 PluginInstance* inst = GetInstance(instance); |
| 119 if (!inst) | 114 if (!inst) |
| 120 return 0; | 115 return 0; |
| 121 return inst->module()->pp_module(); | 116 return inst->module()->pp_module(); |
| 122 } | 117 } |
| 123 | 118 |
| 124 base::Lock* HostGlobals::GetProxyLock() { | |
| 125 // We do not lock on the host side. | |
| 126 return NULL; | |
| 127 } | |
| 128 | |
| 129 PP_Module HostGlobals::AddModule(PluginModule* module) { | 119 PP_Module HostGlobals::AddModule(PluginModule* module) { |
| 130 #ifndef NDEBUG | 120 #ifndef NDEBUG |
| 131 // Make sure we're not adding one more than once. | 121 // Make sure we're not adding one more than once. |
| 132 for (ModuleMap::const_iterator i = module_map_.begin(); | 122 for (ModuleMap::const_iterator i = module_map_.begin(); |
| 133 i != module_map_.end(); ++i) | 123 i != module_map_.end(); ++i) |
| 134 DCHECK(i->second != module); | 124 DCHECK(i->second != module); |
| 135 #endif | 125 #endif |
| 136 | 126 |
| 137 // See AddInstance. | 127 // See AddInstance. |
| 138 PP_Module new_module; | 128 PP_Module new_module; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 190 |
| 201 PluginInstance* HostGlobals::GetInstance(PP_Instance instance) { | 191 PluginInstance* HostGlobals::GetInstance(PP_Instance instance) { |
| 202 DLOG_IF(ERROR, !CheckIdType(instance, ::ppapi::PP_ID_TYPE_INSTANCE)) | 192 DLOG_IF(ERROR, !CheckIdType(instance, ::ppapi::PP_ID_TYPE_INSTANCE)) |
| 203 << instance << " is not a PP_Instance."; | 193 << instance << " is not a PP_Instance."; |
| 204 InstanceMap::iterator found = instance_map_.find(instance); | 194 InstanceMap::iterator found = instance_map_.find(instance); |
| 205 if (found == instance_map_.end()) | 195 if (found == instance_map_.end()) |
| 206 return NULL; | 196 return NULL; |
| 207 return found->second->instance; | 197 return found->second->instance; |
| 208 } | 198 } |
| 209 | 199 |
| 210 bool HostGlobals::IsHostGlobals() const { | |
| 211 return true; | |
| 212 } | |
| 213 | |
| 214 } // namespace ppapi | 200 } // namespace ppapi |
| 215 } // namespace webkit | 201 } // namespace webkit |
| OLD | NEW |