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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 98 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
99 #include "third_party/WebKit/public/web/WebSharedWorkerRepository.h" | 99 #include "third_party/WebKit/public/web/WebSharedWorkerRepository.h" |
100 #include "third_party/WebKit/public/web/WebView.h" | 100 #include "third_party/WebKit/public/web/WebView.h" |
101 #include "third_party/WebKit/public/platform/WebString.h" | 101 #include "third_party/WebKit/public/platform/WebString.h" |
102 #include "ui/base/layout.h" | 102 #include "ui/base/layout.h" |
103 #include "ui/base/ui_base_switches.h" | 103 #include "ui/base/ui_base_switches.h" |
104 #include "v8/include/v8.h" | 104 #include "v8/include/v8.h" |
105 #include "webkit/glue/webkit_glue.h" | 105 #include "webkit/glue/webkit_glue.h" |
106 #include "webkit/child/worker_task_runner.h" | 106 #include "webkit/child/worker_task_runner.h" |
107 #include "webkit/renderer/appcache/appcache_frontend_impl.h" | 107 #include "webkit/renderer/appcache/appcache_frontend_impl.h" |
| 108 #include "webkit/renderer/compositor_bindings/web_external_bitmap_impl.h" |
108 | 109 |
109 #if defined(OS_WIN) | 110 #if defined(OS_WIN) |
110 #include <windows.h> | 111 #include <windows.h> |
111 #include <objbase.h> | 112 #include <objbase.h> |
112 #include "base/win/scoped_com_initializer.h" | 113 #include "base/win/scoped_com_initializer.h" |
113 #else | 114 #else |
114 // TODO(port) | 115 // TODO(port) |
115 #include "base/memory/scoped_handle.h" | 116 #include "base/memory/scoped_handle.h" |
116 #include "content/child/np_channel_base.h" | 117 #include "content/child/np_channel_base.h" |
117 #endif | 118 #endif |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 histogram_name, min, max, buckets, | 210 histogram_name, min, max, buckets, |
210 base::Histogram::kUmaTargetedHistogramFlag); | 211 base::Histogram::kUmaTargetedHistogramFlag); |
211 return histogram; | 212 return histogram; |
212 } | 213 } |
213 | 214 |
214 void AddHistogramSample(void* hist, int sample) { | 215 void AddHistogramSample(void* hist, int sample) { |
215 base::Histogram* histogram = static_cast<base::Histogram*>(hist); | 216 base::Histogram* histogram = static_cast<base::Histogram*>(hist); |
216 histogram->Add(sample); | 217 histogram->Add(sample); |
217 } | 218 } |
218 | 219 |
| 220 scoped_ptr<base::SharedMemory> AllocateSharedMemoryFunction(size_t size) { |
| 221 return RenderThreadImpl::Get()->HostAllocateSharedMemoryBuffer(size); |
| 222 } |
| 223 |
219 } // namespace | 224 } // namespace |
220 | 225 |
221 class RenderThreadImpl::GpuVDAContextLostCallback | 226 class RenderThreadImpl::GpuVDAContextLostCallback |
222 : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback { | 227 : public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback { |
223 public: | 228 public: |
224 GpuVDAContextLostCallback() | 229 GpuVDAContextLostCallback() |
225 : main_message_loop_(base::MessageLoopProxy::current()) {} | 230 : main_message_loop_(base::MessageLoopProxy::current()) {} |
226 virtual ~GpuVDAContextLostCallback() {} | 231 virtual ~GpuVDAContextLostCallback() {} |
227 virtual void onContextLost() { | 232 virtual void onContextLost() { |
228 main_message_loop_->PostTask(FROM_HERE, base::Bind( | 233 main_message_loop_->PostTask(FROM_HERE, base::Bind( |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 WebRuntimeFeatures::enableWebAudio(false); | 721 WebRuntimeFeatures::enableWebAudio(false); |
717 } | 722 } |
718 | 723 |
719 FOR_EACH_OBSERVER(RenderProcessObserver, observers_, WebKitInitialized()); | 724 FOR_EACH_OBSERVER(RenderProcessObserver, observers_, WebKitInitialized()); |
720 | 725 |
721 devtools_agent_message_filter_ = new DevToolsAgentFilter(); | 726 devtools_agent_message_filter_ = new DevToolsAgentFilter(); |
722 AddFilter(devtools_agent_message_filter_.get()); | 727 AddFilter(devtools_agent_message_filter_.get()); |
723 | 728 |
724 if (GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) | 729 if (GetContentClient()->renderer()->RunIdleHandlerWhenWidgetsHidden()) |
725 ScheduleIdleHandler(kLongIdleHandlerDelayMs); | 730 ScheduleIdleHandler(kLongIdleHandlerDelayMs); |
| 731 |
| 732 webkit::SetSharedMemoryAllocationFunction(AllocateSharedMemoryFunction); |
726 } | 733 } |
727 | 734 |
728 void RenderThreadImpl::RegisterSchemes() { | 735 void RenderThreadImpl::RegisterSchemes() { |
729 // swappedout: pages should not be accessible, and should also | 736 // swappedout: pages should not be accessible, and should also |
730 // be treated as empty documents that can commit synchronously. | 737 // be treated as empty documents that can commit synchronously. |
731 WebString swappedout_scheme(ASCIIToUTF16(chrome::kSwappedOutScheme)); | 738 WebString swappedout_scheme(ASCIIToUTF16(chrome::kSwappedOutScheme)); |
732 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(swappedout_scheme); | 739 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(swappedout_scheme); |
733 WebSecurityPolicy::registerURLSchemeAsEmptyDocument(swappedout_scheme); | 740 WebSecurityPolicy::registerURLSchemeAsEmptyDocument(swappedout_scheme); |
734 | 741 |
735 // chrome-native: is a scheme used for placeholder navigations that allow | 742 // chrome-native: is a scheme used for placeholder navigations that allow |
(...skipping 12 matching lines...) Expand all Loading... |
748 | 755 |
749 void RenderThreadImpl::RecordUserMetrics(const std::string& action) { | 756 void RenderThreadImpl::RecordUserMetrics(const std::string& action) { |
750 Send(new ViewHostMsg_UserMetricsRecordAction(action)); | 757 Send(new ViewHostMsg_UserMetricsRecordAction(action)); |
751 } | 758 } |
752 | 759 |
753 scoped_ptr<base::SharedMemory> | 760 scoped_ptr<base::SharedMemory> |
754 RenderThreadImpl::HostAllocateSharedMemoryBuffer(size_t size) { | 761 RenderThreadImpl::HostAllocateSharedMemoryBuffer(size_t size) { |
755 if (size > static_cast<size_t>(std::numeric_limits<int>::max())) | 762 if (size > static_cast<size_t>(std::numeric_limits<int>::max())) |
756 return scoped_ptr<base::SharedMemory>(); | 763 return scoped_ptr<base::SharedMemory>(); |
757 | 764 |
| 765 #if defined(OS_POSIX) |
758 base::SharedMemoryHandle handle; | 766 base::SharedMemoryHandle handle; |
759 bool success; | 767 bool success; |
760 IPC::Message* message = | 768 IPC::Message* message = |
761 new ChildProcessHostMsg_SyncAllocateSharedMemory(size, &handle); | 769 new ChildProcessHostMsg_SyncAllocateSharedMemory(size, &handle); |
762 | 770 |
763 // Allow calling this from the compositor thread. | 771 // Allow calling this from the compositor thread. |
764 if (base::MessageLoop::current() == message_loop()) | 772 if (base::MessageLoop::current() == message_loop()) |
765 success = ChildThread::Send(message); | 773 success = ChildThread::Send(message); |
766 else | 774 else |
767 success = sync_message_filter()->Send(message); | 775 success = sync_message_filter()->Send(message); |
768 | 776 |
769 if (!success) | 777 if (!success) |
770 return scoped_ptr<base::SharedMemory>(); | 778 return scoped_ptr<base::SharedMemory>(); |
771 | 779 |
772 if (!base::SharedMemory::IsHandleValid(handle)) | 780 if (!base::SharedMemory::IsHandleValid(handle)) |
773 return scoped_ptr<base::SharedMemory>(); | 781 return scoped_ptr<base::SharedMemory>(); |
774 | 782 |
775 return scoped_ptr<base::SharedMemory>(new base::SharedMemory(handle, false)); | 783 return scoped_ptr<base::SharedMemory>(new base::SharedMemory(handle, false)); |
| 784 #else |
| 785 scoped_ptr<base::SharedMemory> memory(new base::SharedMemory); |
| 786 |
| 787 if (!memory->CreateAndMapAnonymous(size)) |
| 788 return scoped_ptr<base::SharedMemory>(); |
| 789 return memory.Pass(); |
| 790 #endif |
776 } | 791 } |
777 | 792 |
778 void RenderThreadImpl::RegisterExtension(v8::Extension* extension) { | 793 void RenderThreadImpl::RegisterExtension(v8::Extension* extension) { |
779 WebScriptController::registerExtension(extension); | 794 WebScriptController::registerExtension(extension); |
780 } | 795 } |
781 | 796 |
782 void RenderThreadImpl::ScheduleIdleHandler(int64 initial_delay_ms) { | 797 void RenderThreadImpl::ScheduleIdleHandler(int64 initial_delay_ms) { |
783 idle_notification_delay_in_ms_ = initial_delay_ms; | 798 idle_notification_delay_in_ms_ = initial_delay_ms; |
784 idle_timer_.Stop(); | 799 idle_timer_.Stop(); |
785 idle_timer_.Start(FROM_HERE, | 800 idle_timer_.Start(FROM_HERE, |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1259 | 1274 |
1260 void RenderThreadImpl::SetFlingCurveParameters( | 1275 void RenderThreadImpl::SetFlingCurveParameters( |
1261 const std::vector<float>& new_touchpad, | 1276 const std::vector<float>& new_touchpad, |
1262 const std::vector<float>& new_touchscreen) { | 1277 const std::vector<float>& new_touchscreen) { |
1263 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, | 1278 webkit_platform_support_->SetFlingCurveParameters(new_touchpad, |
1264 new_touchscreen); | 1279 new_touchscreen); |
1265 | 1280 |
1266 } | 1281 } |
1267 | 1282 |
1268 } // namespace content | 1283 } // namespace content |
OLD | NEW |