| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/pepper/host_globals.h" | 5 #include "content/renderer/pepper/host_globals.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/task_runner.h" | 13 #include "base/task_runner.h" |
| 14 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 15 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 15 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 16 #include "content/renderer/pepper/plugin_module.h" | 16 #include "content/renderer/pepper/plugin_module.h" |
| 17 #include "content/renderer/render_thread_impl.h" | 17 #include "content/renderer/render_thread_impl.h" |
| 18 #include "ppapi/shared_impl/api_id.h" | 18 #include "ppapi/shared_impl/api_id.h" |
| 19 #include "ppapi/shared_impl/id_assignment.h" | 19 #include "ppapi/shared_impl/id_assignment.h" |
| 20 #include "ppapi/shared_impl/proxy_lock.h" |
| 20 #include "third_party/WebKit/public/platform/WebString.h" | 21 #include "third_party/WebKit/public/platform/WebString.h" |
| 21 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 22 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
| 22 #include "third_party/WebKit/public/web/WebDocument.h" | 23 #include "third_party/WebKit/public/web/WebDocument.h" |
| 23 #include "third_party/WebKit/public/web/WebElement.h" | 24 #include "third_party/WebKit/public/web/WebElement.h" |
| 24 #include "third_party/WebKit/public/web/WebFrame.h" | 25 #include "third_party/WebKit/public/web/WebFrame.h" |
| 25 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 26 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 26 | 27 |
| 27 using ppapi::CheckIdType; | 28 using ppapi::CheckIdType; |
| 28 using ppapi::MakeTypedId; | 29 using ppapi::MakeTypedId; |
| 29 using ppapi::PPIdType; | 30 using ppapi::PPIdType; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 75 |
| 75 } // namespace | 76 } // namespace |
| 76 | 77 |
| 77 HostGlobals* HostGlobals::host_globals_ = NULL; | 78 HostGlobals* HostGlobals::host_globals_ = NULL; |
| 78 | 79 |
| 79 HostGlobals::HostGlobals() | 80 HostGlobals::HostGlobals() |
| 80 : ppapi::PpapiGlobals(), | 81 : ppapi::PpapiGlobals(), |
| 81 resource_tracker_(ResourceTracker::SINGLE_THREADED) { | 82 resource_tracker_(ResourceTracker::SINGLE_THREADED) { |
| 82 DCHECK(!host_globals_); | 83 DCHECK(!host_globals_); |
| 83 host_globals_ = this; | 84 host_globals_ = this; |
| 84 } | 85 // We do not support calls off of the main thread on the host side, and thus |
| 85 | 86 // do not lock. |
| 86 HostGlobals::HostGlobals( | 87 ppapi::ProxyLock::DisableLocking(); |
| 87 ppapi::PpapiGlobals::PerThreadForTest per_thread_for_test) | |
| 88 : ppapi::PpapiGlobals(per_thread_for_test), | |
| 89 resource_tracker_(ResourceTracker::SINGLE_THREADED) { | |
| 90 DCHECK(!host_globals_); | |
| 91 } | 88 } |
| 92 | 89 |
| 93 HostGlobals::~HostGlobals() { | 90 HostGlobals::~HostGlobals() { |
| 94 DCHECK(host_globals_ == this || !host_globals_); | 91 DCHECK(host_globals_ == this || !host_globals_); |
| 95 host_globals_ = NULL; | 92 host_globals_ = NULL; |
| 96 } | 93 } |
| 97 | 94 |
| 98 ppapi::ResourceTracker* HostGlobals::GetResourceTracker() { | 95 ppapi::ResourceTracker* HostGlobals::GetResourceTracker() { |
| 99 return &resource_tracker_; | 96 return &resource_tracker_; |
| 100 } | 97 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 131 |
| 135 std::string HostGlobals::GetCmdLine() { | 132 std::string HostGlobals::GetCmdLine() { |
| 136 return CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 133 return CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 137 switches::kPpapiFlashArgs); | 134 switches::kPpapiFlashArgs); |
| 138 } | 135 } |
| 139 | 136 |
| 140 void HostGlobals::PreCacheFontForFlash(const void* logfontw) { | 137 void HostGlobals::PreCacheFontForFlash(const void* logfontw) { |
| 141 // Not implemented in-process. | 138 // Not implemented in-process. |
| 142 } | 139 } |
| 143 | 140 |
| 144 base::Lock* HostGlobals::GetProxyLock() { | |
| 145 // We do not lock on the host side. | |
| 146 return NULL; | |
| 147 } | |
| 148 | |
| 149 void HostGlobals::LogWithSource(PP_Instance instance, | 141 void HostGlobals::LogWithSource(PP_Instance instance, |
| 150 PP_LogLevel level, | 142 PP_LogLevel level, |
| 151 const std::string& source, | 143 const std::string& source, |
| 152 const std::string& value) { | 144 const std::string& value) { |
| 153 PepperPluginInstanceImpl* instance_object = | 145 PepperPluginInstanceImpl* instance_object = |
| 154 HostGlobals::Get()->GetInstance(instance); | 146 HostGlobals::Get()->GetInstance(instance); |
| 155 if (instance_object) { | 147 if (instance_object) { |
| 156 instance_object->container()->element().document().frame()-> | 148 instance_object->container()->element().document().frame()-> |
| 157 addMessageToConsole(MakeLogMessage(level, source, value)); | 149 addMessageToConsole(MakeLogMessage(level, source, value)); |
| 158 } else { | 150 } else { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 if (found == instance_map_.end()) | 263 if (found == instance_map_.end()) |
| 272 return NULL; | 264 return NULL; |
| 273 return found->second; | 265 return found->second; |
| 274 } | 266 } |
| 275 | 267 |
| 276 bool HostGlobals::IsHostGlobals() const { | 268 bool HostGlobals::IsHostGlobals() const { |
| 277 return true; | 269 return true; |
| 278 } | 270 } |
| 279 | 271 |
| 280 } // namespace content | 272 } // namespace content |
| OLD | NEW |