Enforce correct thread usage of the core render page objects.
BUG=none
Change-Id: I71a00f93f5382ff1849c05de92ab15b315a8f59f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1529181
Reviewed-by: Daniel Cheng <[email protected]>
Commit-Queue: Avi Drissman <[email protected]>
Cr-Commit-Position: refs/heads/master@{#643906}
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 792fb00..61ae00d 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -53,6 +53,7 @@
#include "content/public/common/service_names.mojom.h"
#include "content/public/common/use_zoom_for_dsf_policy.h"
#include "content/public/renderer/content_renderer_client.h"
+#include "content/public/renderer/render_thread.h"
#include "content/renderer/browser_plugin/browser_plugin.h"
#include "content/renderer/compositor/layer_tree_view.h"
#include "content/renderer/cursor_utils.h"
@@ -475,7 +476,7 @@
warmup_weak_ptr_factory_(this),
weak_ptr_factory_(this) {
DCHECK_NE(routing_id_, MSG_ROUTING_NONE);
- DCHECK(RenderThread::Get());
+ DCHECK(RenderThread::IsMainThread());
// In tests there may not be a RenderThreadImpl.
if (RenderThreadImpl::current()) {
@@ -513,6 +514,7 @@
// static
RenderWidget* RenderWidget::FromRoutingID(int32_t routing_id) {
+ DCHECK(RenderThread::IsMainThread());
RoutingIDWidgetMap* widgets = g_routing_id_widget_map.Pointer();
auto it = widgets->find(routing_id);
return it == widgets->end() ? NULL : it->second;
@@ -711,7 +713,7 @@
}
void RenderWidget::OnClose() {
- DCHECK(content::RenderThread::Get());
+ DCHECK(RenderThread::IsMainThread());
// TODO(crbug.com/939262): If this fails we're handling a WidgetMsg_Close IPC
// in a RenderWidget that is a child local root. This will leave the
// RenderWidget in a closed state while the blink-side is not closed until the
@@ -1896,7 +1898,7 @@
}
void RenderWidget::CloseWidgetSoon() {
- DCHECK(content::RenderThread::Get());
+ DCHECK(RenderThread::IsMainThread());
// Prevent compositor from setting up new IPC channels, since we know a
// WidgetMsg_Close is coming. We do this immediately, not in DoDeferredClose,
// as the caller (eg WebPagePopupImpl) may start tearing down things after