| 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 <utility> | 10 #include <utility> |
| (...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 #if defined(OS_WIN) | 958 #if defined(OS_WIN) |
| 959 // Clean up plugin channels before this thread goes away. | 959 // Clean up plugin channels before this thread goes away. |
| 960 NPChannelBase::CleanupChannels(); | 960 NPChannelBase::CleanupChannels(); |
| 961 #endif | 961 #endif |
| 962 | 962 |
| 963 ChildThreadImpl::Shutdown(); | 963 ChildThreadImpl::Shutdown(); |
| 964 | 964 |
| 965 // Shut down the message loop and the renderer scheduler before shutting down | 965 // Shut down the message loop and the renderer scheduler before shutting down |
| 966 // Blink. This prevents a scenario where a pending task in the message loop | 966 // Blink. This prevents a scenario where a pending task in the message loop |
| 967 // accesses Blink objects after Blink shuts down. | 967 // accesses Blink objects after Blink shuts down. |
| 968 // This must be at the very end of the shutdown sequence. You must not touch | |
| 969 // the message loop after this. | |
| 970 renderer_scheduler_->Shutdown(); | 968 renderer_scheduler_->Shutdown(); |
| 971 main_message_loop_.reset(); | 969 if (main_message_loop_) |
| 970 main_message_loop_->RunUntilIdle(); |
| 971 |
| 972 if (blink_platform_impl_) { | 972 if (blink_platform_impl_) { |
| 973 blink_platform_impl_->Shutdown(); | 973 blink_platform_impl_->Shutdown(); |
| 974 // This must be at the very end of the shutdown sequence. |
| 975 // blink::shutdown() must be called after all strong references from |
| 976 // Chromium to Blink are cleared. |
| 974 blink::shutdown(); | 977 blink::shutdown(); |
| 975 } | 978 } |
| 976 | 979 |
| 980 // Delay shutting down DiscardableSharedMemoryManager until blink::shutdown |
| 981 // is complete, because blink::shutdown destructs Blink Resources and they |
| 982 // may try to unlock their underlying discardable memory. |
| 983 ChildThreadImpl::ShutdownDiscardableSharedMemoryManager(); |
| 984 |
| 985 // The message loop must be cleared after shutting down |
| 986 // the DiscardableSharedMemoryManager, which needs to send messages |
| 987 // to the browser process. |
| 988 main_message_loop_.reset(); |
| 989 |
| 977 lazy_tls.Pointer()->Set(NULL); | 990 lazy_tls.Pointer()->Set(NULL); |
| 978 } | 991 } |
| 979 | 992 |
| 980 bool RenderThreadImpl::Send(IPC::Message* msg) { | 993 bool RenderThreadImpl::Send(IPC::Message* msg) { |
| 981 // Certain synchronous messages cannot always be processed synchronously by | 994 // Certain synchronous messages cannot always be processed synchronously by |
| 982 // the browser, e.g., putting up UI and waiting for the user. This could cause | 995 // the browser, e.g., putting up UI and waiting for the user. This could cause |
| 983 // a complete hang of Chrome if a windowed plugin is trying to communicate | 996 // a complete hang of Chrome if a windowed plugin is trying to communicate |
| 984 // with the renderer thread since the browser's UI thread could be stuck | 997 // with the renderer thread since the browser's UI thread could be stuck |
| 985 // (within a Windows API call) trying to synchronously communicate with the | 998 // (within a Windows API call) trying to synchronously communicate with the |
| 986 // plugin. The remedy is to pump messages on this thread while the browser | 999 // plugin. The remedy is to pump messages on this thread while the browser |
| (...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2124 } | 2137 } |
| 2125 | 2138 |
| 2126 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { | 2139 void RenderThreadImpl::PendingRenderFrameConnect::OnConnectionError() { |
| 2127 size_t erased = | 2140 size_t erased = |
| 2128 RenderThreadImpl::current()->pending_render_frame_connects_.erase( | 2141 RenderThreadImpl::current()->pending_render_frame_connects_.erase( |
| 2129 routing_id_); | 2142 routing_id_); |
| 2130 DCHECK_EQ(1u, erased); | 2143 DCHECK_EQ(1u, erased); |
| 2131 } | 2144 } |
| 2132 | 2145 |
| 2133 } // namespace content | 2146 } // namespace content |
| OLD | NEW |