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/render_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h " | 93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptController.h " |
94 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" | 94 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
95 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSharedWorkerReposi tory.h" | 95 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSharedWorkerReposi tory.h" |
96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
97 #include "third_party/WebKit/public/platform/WebString.h" | 97 #include "third_party/WebKit/public/platform/WebString.h" |
98 #include "ui/base/layout.h" | 98 #include "ui/base/layout.h" |
99 #include "ui/base/ui_base_switches.h" | 99 #include "ui/base/ui_base_switches.h" |
100 #include "v8/include/v8.h" | 100 #include "v8/include/v8.h" |
101 #include "webkit/glue/webkit_glue.h" | 101 #include "webkit/glue/webkit_glue.h" |
102 #include "webkit/renderer/appcache/appcache_frontend_impl.h" | 102 #include "webkit/renderer/appcache/appcache_frontend_impl.h" |
103 #include "webkit/renderer/compositor_bindings/web_external_bitmap_impl.h" | |
103 | 104 |
104 #if defined(OS_WIN) | 105 #if defined(OS_WIN) |
105 #include <windows.h> | 106 #include <windows.h> |
106 #include <objbase.h> | 107 #include <objbase.h> |
107 #include "base/win/scoped_com_initializer.h" | 108 #include "base/win/scoped_com_initializer.h" |
108 #else | 109 #else |
109 // TODO(port) | 110 // TODO(port) |
110 #include "base/memory/scoped_handle.h" | 111 #include "base/memory/scoped_handle.h" |
111 #include "content/child/np_channel_base.h" | 112 #include "content/child/np_channel_base.h" |
112 #endif | 113 #endif |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 const char** arg_names, | 229 const char** arg_names, |
229 const unsigned char* arg_types, | 230 const unsigned char* arg_types, |
230 const unsigned long long* arg_values, | 231 const unsigned long long* arg_values, |
231 unsigned char flags) { | 232 unsigned char flags) { |
232 TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_group_enabled, name, id, | 233 TRACE_EVENT_API_ADD_TRACE_EVENT(phase, category_group_enabled, name, id, |
233 num_args, arg_names, arg_types, arg_values, | 234 num_args, arg_names, arg_types, arg_values, |
234 NULL, flags); | 235 NULL, flags); |
235 } | 236 } |
236 #endif | 237 #endif |
237 | 238 |
239 scoped_ptr<base::SharedMemory> AllocateSharedMemoryFunction(size_t size) { | |
240 return RenderThreadImpl::Get()->HostAllocateSharedMemoryBuffer(size); | |
241 } | |
242 | |
238 } // namespace | 243 } // namespace |
239 | 244 |
240 class RenderThreadImpl::GpuVDAContextLostCallback | 245 class RenderThreadImpl::GpuVDAContextLostCallback |
241 : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback { | 246 : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback { |
242 public: | 247 public: |
243 GpuVDAContextLostCallback() {} | 248 GpuVDAContextLostCallback() {} |
244 virtual ~GpuVDAContextLostCallback() {} | 249 virtual ~GpuVDAContextLostCallback() {} |
245 virtual void onContextLost() { | 250 virtual void onContextLost() { |
246 ChildThread::current()->message_loop()->PostTask(FROM_HERE, base::Bind( | 251 ChildThread::current()->message_loop()->PostTask(FROM_HERE, base::Bind( |
247 &RenderThreadImpl::OnGpuVDAContextLoss)); | 252 &RenderThreadImpl::OnGpuVDAContextLoss)); |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
719 WebRuntimeFeatures::enableWebAudio(false); | 724 WebRuntimeFeatures::enableWebAudio(false); |
720 } | 725 } |
721 | 726 |
722 FOR_EACH_OBSERVER(RenderProcessObserver, observers_, WebKitInitialized()); | 727 FOR_EACH_OBSERVER(RenderProcessObserver, observers_, WebKitInitialized()); |
723 | 728 |
724 devtools_agent_message_filter_ = new DevToolsAgentFilter(); | 729 devtools_agent_message_filter_ = new DevToolsAgentFilter(); |
725 AddFilter(devtools_agent_message_filter_.get()); | 730 AddFilter(devtools_agent_message_filter_.get()); |
726 | 731 |
727 if (GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) | 732 if (GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) |
728 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 733 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
734 | |
735 webkit::SetSharedMemoryAllocationFunction(AllocateSharedMemoryFunction); | |
729 } | 736 } |
730 | 737 |
731 void RenderThreadImpl::RegisterSchemes() { | 738 void RenderThreadImpl::RegisterSchemes() { |
732 // swappedout: pages should not be accessible, and should also | 739 // swappedout: pages should not be accessible, and should also |
733 // be treated as empty documents that can commit synchronously. | 740 // be treated as empty documents that can commit synchronously. |
734 WebString swappedout_scheme(ASCIIToUTF16(chrome::kSwappedOutScheme)); | 741 WebString swappedout_scheme(ASCIIToUTF16(chrome::kSwappedOutScheme)); |
735 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(swappedout_scheme); | 742 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(swappedout_scheme); |
736 WebSecurityPolicy::registerURLSchemeAsEmptyDocument(swappedout_scheme); | 743 WebSecurityPolicy::registerURLSchemeAsEmptyDocument(swappedout_scheme); |
737 } | 744 } |
738 | 745 |
739 void RenderThreadImpl::RecordUserMetrics(const std::string& action) { | 746 void RenderThreadImpl::RecordUserMetrics(const std::string& action) { |
740 Send(new ViewHostMsg_UserMetricsRecordAction(action)); | 747 Send(new ViewHostMsg_UserMetricsRecordAction(action)); |
741 } | 748 } |
742 | 749 |
743 scoped_ptr<base::SharedMemory> | 750 scoped_ptr<base::SharedMemory> |
744 RenderThreadImpl::HostAllocateSharedMemoryBuffer(size_t size) { | 751 RenderThreadImpl::HostAllocateSharedMemoryBuffer(size_t size) { |
745 if (size > static_cast<size_t>(std::numeric_limits<int>::max())) | 752 if (size > static_cast<size_t>(std::numeric_limits<int>::max())) |
746 return scoped_ptr<base::SharedMemory>(); | 753 return scoped_ptr<base::SharedMemory>(); |
747 | 754 |
755 #if defined(OS_POSIX) | |
piman
2013/07/01 22:45:01
Why the ifdef? This method was sucessfully used on
jbauman
2013/07/02 00:00:40
Sure, but I'd prefer not to have a round-trip to t
piman
2013/07/02 04:00:09
I see, that's an optimization. Maybe worth separat
jbauman
2013/07/02 20:16:19
Ok, I've removed this change and I'll do that in a
| |
748 base::SharedMemoryHandle handle; | 756 base::SharedMemoryHandle handle; |
749 bool success; | 757 bool success; |
750 IPC::Message* message = | 758 IPC::Message* message = |
751 new ChildProcessHostMsg_SyncAllocateSharedMemory(size, &handle); | 759 new ChildProcessHostMsg_SyncAllocateSharedMemory(size, &handle); |
752 | 760 |
753 // Allow calling this from the compositor thread. | 761 // Allow calling this from the compositor thread. |
754 if (base::MessageLoop::current() == message_loop()) | 762 if (base::MessageLoop::current() == message_loop()) |
755 success = ChildThread::Send(message); | 763 success = ChildThread::Send(message); |
756 else | 764 else |
757 success = sync_message_filter()->Send(message); | 765 success = sync_message_filter()->Send(message); |
758 | 766 |
759 if (!success) | 767 if (!success) |
760 return scoped_ptr<base::SharedMemory>(); | 768 return scoped_ptr<base::SharedMemory>(); |
761 | 769 |
762 if (!base::SharedMemory::IsHandleValid(handle)) | 770 if (!base::SharedMemory::IsHandleValid(handle)) |
763 return scoped_ptr<base::SharedMemory>(); | 771 return scoped_ptr<base::SharedMemory>(); |
764 | 772 |
765 return scoped_ptr<base::SharedMemory>(new base::SharedMemory(handle, false)); | 773 return scoped_ptr<base::SharedMemory>(new base::SharedMemory(handle, false)); |
774 #else | |
775 scoped_ptr<base::SharedMemory> memory(new base::SharedMemory); | |
776 | |
777 if (!memory->CreateAndMapAnonymous(size)) | |
778 return scoped_ptr<base::SharedMemory>(); | |
779 return memory.Pass(); | |
780 #endif | |
766 } | 781 } |
767 | 782 |
768 void RenderThreadImpl::RegisterExtension(v8::Extension* extension) { | 783 void RenderThreadImpl::RegisterExtension(v8::Extension* extension) { |
769 WebScriptController::registerExtension(extension); | 784 WebScriptController::registerExtension(extension); |
770 } | 785 } |
771 | 786 |
772 void RenderThreadImpl::ScheduleIdleHandler(int64 initial_delay_ms) { | 787 void RenderThreadImpl::ScheduleIdleHandler(int64 initial_delay_ms) { |
773 idle_notification_delay_in_ms_ = initial_delay_ms; | 788 idle_notification_delay_in_ms_ = initial_delay_ms; |
774 idle_timer_.Stop(); | 789 idle_timer_.Stop(); |
775 idle_timer_.Start(FROM_HERE, | 790 idle_timer_.Start(FROM_HERE, |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1252 | 1267 |
1253 void RenderThreadImpl::SetFlingCurveParameters( | 1268 void RenderThreadImpl::SetFlingCurveParameters( |
1254 const std::vector<float>& new_touchpad, | 1269 const std::vector<float>& new_touchpad, |
1255 const std::vector<float>& new_touchscreen) { | 1270 const std::vector<float>& new_touchscreen) { |
1256 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, | 1271 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, |
1257 new_touchscreen); | 1272 new_touchscreen); |
1258 | 1273 |
1259 } | 1274 } |
1260 | 1275 |
1261 } // namespace content | 1276 } // namespace content |
OLD | NEW |