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

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

Issue 2309153002: Remove RenderThreadImpl::Shutdown (Closed)
Patch Set: temp Created 3 years, 11 months 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
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 <utility> 10 #include <utility>
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 // SequencedWorkerPool. Otherwise, it should already have been enabled. 929 // SequencedWorkerPool. Otherwise, it should already have been enabled.
930 // TODO(fdoray): Remove this once the SequencedWorkerPool to TaskScheduler 930 // TODO(fdoray): Remove this once the SequencedWorkerPool to TaskScheduler
931 // redirection experiment concludes https://crbug.com/622400. 931 // redirection experiment concludes https://crbug.com/622400.
932 if (!command_line.HasSwitch(switches::kSingleProcess)) 932 if (!command_line.HasSwitch(switches::kSingleProcess))
933 base::SequencedWorkerPool::EnableForProcess(); 933 base::SequencedWorkerPool::EnableForProcess();
934 } 934 }
935 935
936 RenderThreadImpl::~RenderThreadImpl() { 936 RenderThreadImpl::~RenderThreadImpl() {
937 } 937 }
938 938
939 void RenderThreadImpl::Shutdown() {
Torne 2017/01/11 12:50:58 Should we keep the override of Shutdown and just h
940 for (auto& observer : observers_)
941 observer.OnRenderProcessShutdown();
942
943 if (memory_observer_) {
944 message_loop()->RemoveTaskObserver(memory_observer_.get());
945 memory_observer_.reset();
946 }
947
948 // Wait for all databases to be closed.
949 if (blink_platform_impl_) {
950 // Crash the process if they fail to close after a generous amount of time.
951 bool all_closed = blink_platform_impl_->web_database_observer_impl()
952 ->WaitForAllDatabasesToClose(base::TimeDelta::FromSeconds(60));
953 CHECK(all_closed);
954 }
955
956 // Shutdown in reverse of the initialization order.
957 if (devtools_agent_message_filter_.get()) {
958 RemoveFilter(devtools_agent_message_filter_.get());
959 devtools_agent_message_filter_ = nullptr;
960 }
961
962 RemoveFilter(audio_input_message_filter_.get());
963 audio_input_message_filter_ = nullptr;
964
965 #if BUILDFLAG(ENABLE_WEBRTC)
966 RTCPeerConnectionHandler::DestructAllHandlers();
967 // |peer_connection_factory_| cannot be deleted until after the main message
968 // loop has been destroyed. This is because there may be pending tasks that
969 // hold on to objects produced by the PC factory that depend on threads owned
970 // by the PC factory. Once those tasks have been freed, the factory can be
971 // deleted.
972 #endif
973 vc_manager_.reset();
974
975 RemoveFilter(db_message_filter_.get());
976 db_message_filter_ = nullptr;
977
978 // Shutdown the file thread if it's running.
979 if (file_thread_)
980 file_thread_->Stop();
981
982 if (compositor_message_filter_.get()) {
983 RemoveFilter(compositor_message_filter_.get());
984 compositor_message_filter_ = nullptr;
985 }
986
987 #if defined(OS_ANDROID)
988 if (sync_compositor_message_filter_) {
989 RemoveFilter(sync_compositor_message_filter_.get());
990 sync_compositor_message_filter_ = nullptr;
991 }
992 stream_texture_factory_ = nullptr;
993 #endif
994
995 media_thread_.reset();
996
997 blink_platform_impl_->SetCompositorThread(nullptr);
998
999 compositor_thread_.reset();
1000
1001 // AudioMessageFilter may be accessed on |media_thread_|, so shutdown after.
1002 RemoveFilter(audio_message_filter_.get());
1003 audio_message_filter_ = nullptr;
1004
1005 categorized_worker_pool_->Shutdown();
1006
1007 main_input_callback_.Cancel();
1008 input_handler_manager_.reset();
1009 if (input_event_filter_.get()) {
1010 RemoveFilter(input_event_filter_.get());
1011 input_event_filter_ = nullptr;
1012 }
1013
1014 // RemoveEmbeddedWorkerRoute may be called while deleting
1015 // EmbeddedWorkerDispatcher. So it must be deleted before deleting
1016 // RenderThreadImpl.
1017 embedded_worker_dispatcher_.reset();
1018
1019 // Ramp down IDB before we ramp down WebKit (and V8), since IDB classes might
1020 // hold pointers to V8 objects (e.g., via pending requests).
1021 main_thread_indexed_db_dispatcher_.reset();
1022
1023 main_thread_compositor_task_runner_ = nullptr;
1024
1025 gpu_factories_.clear();
1026
1027 // Context providers must be released prior to destroying the GPU channel.
1028 shared_worker_context_provider_ = nullptr;
1029 shared_main_thread_contexts_ = nullptr;
1030
1031 if (gpu_channel_.get())
1032 gpu_channel_->DestroyChannel();
1033
1034 ChildThreadImpl::Shutdown();
1035
1036 // Shut down the message loop (if provided when the RenderThreadImpl was
1037 // constructed) and the renderer scheduler before shutting down Blink. This
1038 // prevents a scenario where a pending task in the message loop accesses Blink
1039 // objects after Blink shuts down.
1040 renderer_scheduler_->SetRAILModeObserver(nullptr);
1041 renderer_scheduler_->Shutdown();
1042 if (main_message_loop_)
1043 base::RunLoop().RunUntilIdle();
1044
1045 if (blink_platform_impl_) {
1046 blink_platform_impl_->Shutdown();
1047 // This must be at the very end of the shutdown sequence.
1048 // blink::shutdown() must be called after all strong references from
1049 // Chromium to Blink are cleared.
1050 blink::shutdown();
1051 }
1052
1053 // Delay shutting down DiscardableSharedMemoryManager until blink::shutdown
1054 // is complete, because blink::shutdown destructs Blink Resources and they
1055 // may try to unlock their underlying discardable memory.
1056 discardable_shared_memory_manager_.reset();
1057
1058 // The message loop must be cleared after shutting down
1059 // the DiscardableSharedMemoryManager, which needs to send messages
1060 // to the browser process.
1061 main_message_loop_.reset();
1062
1063 lazy_tls.Pointer()->Set(nullptr);
1064
1065 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this);
1066 }
1067
1068 bool RenderThreadImpl::Send(IPC::Message* msg) { 939 bool RenderThreadImpl::Send(IPC::Message* msg) {
1069 // There are cases where we want to pump asynchronous messages while waiting 940 // There are cases where we want to pump asynchronous messages while waiting
1070 // synchronously for the replies to the message to be sent here. However, this 941 // synchronously for the replies to the message to be sent here. However, this
1071 // may create an opportunity for re-entrancy into WebKit and other subsystems, 942 // may create an opportunity for re-entrancy into WebKit and other subsystems,
1072 // so we need to take care to disable callbacks, timers, and pending network 943 // so we need to take care to disable callbacks, timers, and pending network
1073 // loads that could trigger such callbacks. 944 // loads that could trigger such callbacks.
1074 bool pumping_events = false; 945 bool pumping_events = false;
1075 if (msg->is_sync()) { 946 if (msg->is_sync()) {
1076 if (msg->is_caller_pumping_messages()) { 947 if (msg->is_caller_pumping_messages()) {
1077 pumping_events = true; 948 pumping_events = true;
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 } 1466 }
1596 1467
1597 base::WaitableEvent* RenderThreadImpl::GetShutdownEvent() { 1468 base::WaitableEvent* RenderThreadImpl::GetShutdownEvent() {
1598 return ChildProcess::current()->GetShutDownEvent(); 1469 return ChildProcess::current()->GetShutDownEvent();
1599 } 1470 }
1600 1471
1601 int32_t RenderThreadImpl::GetClientId() { 1472 int32_t RenderThreadImpl::GetClientId() {
1602 return client_id_; 1473 return client_id_;
1603 } 1474 }
1604 1475
1476 bool RenderThreadImpl::IsRenderThread() {
1477 return true;
1478 }
1479
1605 void RenderThreadImpl::OnAssociatedInterfaceRequest( 1480 void RenderThreadImpl::OnAssociatedInterfaceRequest(
1606 const std::string& name, 1481 const std::string& name,
1607 mojo::ScopedInterfaceEndpointHandle handle) { 1482 mojo::ScopedInterfaceEndpointHandle handle) {
1608 associated_interfaces_.BindRequest(name, std::move(handle)); 1483 associated_interfaces_.BindRequest(name, std::move(handle));
1609 } 1484 }
1610 1485
1611 bool RenderThreadImpl::IsGpuRasterizationForced() { 1486 bool RenderThreadImpl::IsGpuRasterizationForced() {
1612 return is_gpu_rasterization_forced_; 1487 return is_gpu_rasterization_forced_;
1613 } 1488 }
1614 1489
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
2501 } 2376 }
2502 } 2377 }
2503 2378
2504 void RenderThreadImpl::OnRendererInterfaceRequest( 2379 void RenderThreadImpl::OnRendererInterfaceRequest(
2505 mojom::RendererAssociatedRequest request) { 2380 mojom::RendererAssociatedRequest request) {
2506 DCHECK(!renderer_binding_.is_bound()); 2381 DCHECK(!renderer_binding_.is_bound());
2507 renderer_binding_.Bind(std::move(request)); 2382 renderer_binding_.Bind(std::move(request));
2508 } 2383 }
2509 2384
2510 } // namespace content 2385 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698