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