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/renderer_webkitplatformsupport_impl.h" | 5 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/metrics/histogram.h" |
10 #include "base/platform_file.h" | 11 #include "base/platform_file.h" |
11 #include "base/shared_memory.h" | 12 #include "base/shared_memory.h" |
12 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
13 #include "content/common/database_util.h" | 14 #include "content/common/database_util.h" |
14 #include "content/common/fileapi/webblobregistry_impl.h" | 15 #include "content/common/fileapi/webblobregistry_impl.h" |
15 #include "content/common/fileapi/webfilesystem_impl.h" | 16 #include "content/common/fileapi/webfilesystem_impl.h" |
16 #include "content/common/file_utilities_messages.h" | 17 #include "content/common/file_utilities_messages.h" |
17 #include "content/common/indexed_db/proxy_webidbfactory_impl.h" | 18 #include "content/common/indexed_db/proxy_webidbfactory_impl.h" |
18 #include "content/common/mime_registry_messages.h" | 19 #include "content/common/mime_registry_messages.h" |
19 #include "content/common/npobject_util.h" | 20 #include "content/common/npobject_util.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 sandbox_support_(new RendererWebKitPlatformSupportImpl::SandboxSupport), | 167 sandbox_support_(new RendererWebKitPlatformSupportImpl::SandboxSupport), |
167 sudden_termination_disables_(0), | 168 sudden_termination_disables_(0), |
168 shared_worker_repository_(new WebSharedWorkerRepositoryImpl) { | 169 shared_worker_repository_(new WebSharedWorkerRepositoryImpl) { |
169 } | 170 } |
170 | 171 |
171 RendererWebKitPlatformSupportImpl::~RendererWebKitPlatformSupportImpl() { | 172 RendererWebKitPlatformSupportImpl::~RendererWebKitPlatformSupportImpl() { |
172 } | 173 } |
173 | 174 |
174 //------------------------------------------------------------------------------ | 175 //------------------------------------------------------------------------------ |
175 | 176 |
| 177 namespace { |
| 178 |
| 179 bool SendSyncMessageFromAnyThreadInternal(IPC::SyncMessage* msg) { |
| 180 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 181 if (render_thread) |
| 182 return render_thread->Send(msg); |
| 183 scoped_refptr<IPC::SyncMessageFilter> sync_msg_filter( |
| 184 ChildThread::current()->sync_message_filter()); |
| 185 return sync_msg_filter->Send(msg); |
| 186 } |
| 187 |
| 188 bool SendSyncMessageFromAnyThread(IPC::SyncMessage* msg) { |
| 189 base::TimeTicks begin = base::TimeTicks::Now(); |
| 190 const bool success = SendSyncMessageFromAnyThreadInternal(msg); |
| 191 base::TimeDelta delta = base::TimeTicks::Now() - begin; |
| 192 HISTOGRAM_TIMES("RendererSyncIPC.ElapsedTime", delta); |
| 193 return success; |
| 194 } |
| 195 |
| 196 } // namespace |
| 197 |
176 WebKit::WebClipboard* RendererWebKitPlatformSupportImpl::clipboard() { | 198 WebKit::WebClipboard* RendererWebKitPlatformSupportImpl::clipboard() { |
177 return clipboard_.get(); | 199 return clipboard_.get(); |
178 } | 200 } |
179 | 201 |
180 WebKit::WebMimeRegistry* RendererWebKitPlatformSupportImpl::mimeRegistry() { | 202 WebKit::WebMimeRegistry* RendererWebKitPlatformSupportImpl::mimeRegistry() { |
181 return mime_registry_.get(); | 203 return mime_registry_.get(); |
182 } | 204 } |
183 | 205 |
184 WebKit::WebFileUtilities* | 206 WebKit::WebFileUtilities* |
185 RendererWebKitPlatformSupportImpl::fileUtilities() { | 207 RendererWebKitPlatformSupportImpl::fileUtilities() { |
(...skipping 22 matching lines...) Expand all Loading... |
208 // As explained in WebKitPlatformSupport.h, this function is used to decide | 230 // As explained in WebKitPlatformSupport.h, this function is used to decide |
209 // whether to allow file system operations to come out of WebKit or not. | 231 // whether to allow file system operations to come out of WebKit or not. |
210 // Even if the sandbox is disabled, there's no reason why the code should | 232 // Even if the sandbox is disabled, there's no reason why the code should |
211 // act any differently...unless we're in single process mode. In which | 233 // act any differently...unless we're in single process mode. In which |
212 // case, we have no other choice. WebKitPlatformSupport.h discourages using | 234 // case, we have no other choice. WebKitPlatformSupport.h discourages using |
213 // this switch unless absolutely necessary, so hopefully we won't end up | 235 // this switch unless absolutely necessary, so hopefully we won't end up |
214 // with too many code paths being different in single-process mode. | 236 // with too many code paths being different in single-process mode. |
215 return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); | 237 return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); |
216 } | 238 } |
217 | 239 |
218 bool RendererWebKitPlatformSupportImpl::SendSyncMessageFromAnyThread( | |
219 IPC::SyncMessage* msg) { | |
220 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | |
221 if (render_thread) | |
222 return render_thread->Send(msg); | |
223 | |
224 scoped_refptr<IPC::SyncMessageFilter> sync_msg_filter( | |
225 ChildThread::current()->sync_message_filter()); | |
226 return sync_msg_filter->Send(msg); | |
227 } | |
228 | |
229 unsigned long long RendererWebKitPlatformSupportImpl::visitedLinkHash( | 240 unsigned long long RendererWebKitPlatformSupportImpl::visitedLinkHash( |
230 const char* canonical_url, | 241 const char* canonical_url, |
231 size_t length) { | 242 size_t length) { |
232 return content::GetContentClient()->renderer()->VisitedLinkHash( | 243 return content::GetContentClient()->renderer()->VisitedLinkHash( |
233 canonical_url, length); | 244 canonical_url, length); |
234 } | 245 } |
235 | 246 |
236 bool RendererWebKitPlatformSupportImpl::isLinkVisited( | 247 bool RendererWebKitPlatformSupportImpl::isLinkVisited( |
237 unsigned long long link_hash) { | 248 unsigned long long link_hash) { |
238 return content::GetContentClient()->renderer()->IsLinkVisited(link_hash); | 249 return content::GetContentClient()->renderer()->IsLinkVisited(link_hash); |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 DCHECK(render_thread); | 715 DCHECK(render_thread); |
705 if (!render_thread) | 716 if (!render_thread) |
706 return NULL; | 717 return NULL; |
707 return render_thread->CreateMediaStreamCenter(client); | 718 return render_thread->CreateMediaStreamCenter(client); |
708 } | 719 } |
709 | 720 |
710 GpuChannelHostFactory* | 721 GpuChannelHostFactory* |
711 RendererWebKitPlatformSupportImpl::GetGpuChannelHostFactory() { | 722 RendererWebKitPlatformSupportImpl::GetGpuChannelHostFactory() { |
712 return RenderThreadImpl::current(); | 723 return RenderThreadImpl::current(); |
713 } | 724 } |
OLD | NEW |