Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(997)

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 11469015: Renderer process can allocate anonymous shared memory without help from browser process on Windows. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: rebase Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 // be treated as empty documents that can commit synchronously. 712 // be treated as empty documents that can commit synchronously.
713 WebString swappedout_scheme(ASCIIToUTF16(chrome::kSwappedOutScheme)); 713 WebString swappedout_scheme(ASCIIToUTF16(chrome::kSwappedOutScheme));
714 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(swappedout_scheme); 714 WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(swappedout_scheme);
715 WebSecurityPolicy::registerURLSchemeAsEmptyDocument(swappedout_scheme); 715 WebSecurityPolicy::registerURLSchemeAsEmptyDocument(swappedout_scheme);
716 } 716 }
717 717
718 void RenderThreadImpl::RecordUserMetrics(const std::string& action) { 718 void RenderThreadImpl::RecordUserMetrics(const std::string& action) {
719 Send(new ViewHostMsg_UserMetricsRecordAction(action)); 719 Send(new ViewHostMsg_UserMetricsRecordAction(action));
720 } 720 }
721 721
722 base::SharedMemoryHandle RenderThreadImpl::HostAllocateSharedMemoryBuffer( 722 scoped_ptr<base::SharedMemory>
723 uint32 buffer_size) { 723 RenderThreadImpl::HostAllocateSharedMemoryBuffer(uint32 size) {
724 base::SharedMemoryHandle mem_handle = base::SharedMemoryHandle(); 724 //if (!size)
725 Send(new ChildProcessHostMsg_SyncAllocateSharedMemory( 725 // return scoped_ptr<base::SharedMemory>();
726 buffer_size, &mem_handle)); 726
727 return mem_handle; 727 //#if defined(OS_WIN)
728 // scoped_ptr<base::SharedMemory> shared_memory(new base::SharedMemory);
729 // if (!shared_memory->CreateAnonymous(size))
730 // return scoped_ptr<base::SharedMemory>();
731 //
732 // return scoped_ptr<base::SharedMemory>(shared_memory.release());
733 //#else
734 base::SharedMemoryHandle handle;
735 bool success;
736 IPC::Message* message =
737 new ChildProcessHostMsg_SyncAllocateSharedMemory(size, &handle);
738
739 // Allow calling this from the compositor thread.
740 if (MessageLoop::current() == message_loop())
741 success = ChildThread::Send(message);
742 else
743 success = sync_message_filter()->Send(message);
744
745 if (!success)
746 return scoped_ptr<base::SharedMemory>();
747
748 if (!base::SharedMemory::IsHandleValid(handle))
749 return scoped_ptr<base::SharedMemory>();
750
751 return scoped_ptr<base::SharedMemory>(new base::SharedMemory(handle, false));
752 //#endif // defined(OS_WIN)
728 } 753 }
729 754
730 void RenderThreadImpl::RegisterExtension(v8::Extension* extension) { 755 void RenderThreadImpl::RegisterExtension(v8::Extension* extension) {
731 WebScriptController::registerExtension(extension); 756 WebScriptController::registerExtension(extension);
732 } 757 }
733 758
734 void RenderThreadImpl::ScheduleIdleHandler(int64 initial_delay_ms) { 759 void RenderThreadImpl::ScheduleIdleHandler(int64 initial_delay_ms) {
735 idle_notification_delay_in_ms_ = initial_delay_ms; 760 idle_notification_delay_in_ms_ = initial_delay_ms;
736 idle_timer_.Stop(); 761 idle_timer_.Stop();
737 idle_timer_.Start(FROM_HERE, 762 idle_timer_.Start(FROM_HERE,
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 scoped_refptr<base::MessageLoopProxy> RenderThreadImpl::GetIOLoopProxy() { 928 scoped_refptr<base::MessageLoopProxy> RenderThreadImpl::GetIOLoopProxy() {
904 return ChildProcess::current()->io_message_loop_proxy(); 929 return ChildProcess::current()->io_message_loop_proxy();
905 } 930 }
906 931
907 base::WaitableEvent* RenderThreadImpl::GetShutDownEvent() { 932 base::WaitableEvent* RenderThreadImpl::GetShutDownEvent() {
908 return ChildProcess::current()->GetShutDownEvent(); 933 return ChildProcess::current()->GetShutDownEvent();
909 } 934 }
910 935
911 scoped_ptr<base::SharedMemory> RenderThreadImpl::AllocateSharedMemory( 936 scoped_ptr<base::SharedMemory> RenderThreadImpl::AllocateSharedMemory(
912 uint32 size) { 937 uint32 size) {
913 base::SharedMemoryHandle handle; 938 return scoped_ptr<base::SharedMemory>(
914 bool success; 939 HostAllocateSharedMemoryBuffer(size));
915 IPC::Message* message =
916 new ChildProcessHostMsg_SyncAllocateSharedMemory(size, &handle);
917
918 // Allow calling this from the compositor thread.
919 if (MessageLoop::current() == message_loop())
920 success = ChildThread::Send(message);
921 else
922 success = sync_message_filter()->Send(message);
923
924 if (!success)
925 return scoped_ptr<base::SharedMemory>();
926
927 if (!base::SharedMemory::IsHandleValid(handle))
928 return scoped_ptr<base::SharedMemory>();
929 return scoped_ptr<base::SharedMemory>(new base::SharedMemory(handle, false));
930 } 940 }
931 941
932 int32 RenderThreadImpl::CreateViewCommandBuffer( 942 int32 RenderThreadImpl::CreateViewCommandBuffer(
933 int32 surface_id, const GPUCreateCommandBufferConfig& init_params) { 943 int32 surface_id, const GPUCreateCommandBufferConfig& init_params) {
934 TRACE_EVENT1("gpu", 944 TRACE_EVENT1("gpu",
935 "RenderThreadImpl::CreateViewCommandBuffer", 945 "RenderThreadImpl::CreateViewCommandBuffer",
936 "surface_id", 946 "surface_id",
937 surface_id); 947 surface_id);
938 948
939 int32 route_id = MSG_ROUTING_NONE; 949 int32 route_id = MSG_ROUTING_NONE;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 RenderThreadImpl::GetFileThreadMessageLoopProxy() { 1134 RenderThreadImpl::GetFileThreadMessageLoopProxy() {
1125 DCHECK(message_loop() == MessageLoop::current()); 1135 DCHECK(message_loop() == MessageLoop::current());
1126 if (!file_thread_.get()) { 1136 if (!file_thread_.get()) {
1127 file_thread_.reset(new base::Thread("Renderer::FILE")); 1137 file_thread_.reset(new base::Thread("Renderer::FILE"));
1128 file_thread_->Start(); 1138 file_thread_->Start();
1129 } 1139 }
1130 return file_thread_->message_loop_proxy(); 1140 return file_thread_->message_loop_proxy();
1131 } 1141 }
1132 1142
1133 } // namespace content 1143 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698