Commit 821ebe6c authored by Justin Donnelly's avatar Justin Donnelly Committed by Commit Bot

Revert "[jumbo] Make it one g_id_map instead of two."

This reverts commit 41aadb51.

Reason for revert: Introduces static initializers according to https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/mac-rel/552.

Original change's description:
> [jumbo] Make it one g_id_map instead of two.
> 
> A commit just introduced a second g_id_map in ui/views/cocoa,
> which broke jumbo builds. This renames the g_id_map
> globals to the longer names g_id_to_impl_map and
> g_id_to_host_impl_map.
> 
> Bug: 859152
> 
> TBR=ccameron@chromium.org,ellyjones@chromium.org
> 
> Change-Id: Id30d71b67f4bfb7c3ddc3ec8d03c759b5b7df14f
> Reviewed-on: https://chromium-review.googlesource.com/1212862
> Reviewed-by: Daniel Bratell <bratell@opera.com>
> Commit-Queue: Daniel Bratell <bratell@opera.com>
> Cr-Commit-Position: refs/heads/master@{#589465}

TBR=ellyjones@chromium.org,ccameron@chromium.org,bratell@opera.com

Change-Id: I70fdf14f4759f74e9572e0b69884febb2607adcc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 859152
Reviewed-on: https://chromium-review.googlesource.com/1213705Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Commit-Queue: Justin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589620}
parent 26fbd76c
......@@ -227,7 +227,7 @@ NSUInteger CountBridgedWindows(NSArray* child_windows) {
}
static base::NoDestructor<std::map<uint64_t, BridgedNativeWidgetImpl*>>
g_id_to_impl_map;
g_id_map;
} // namespace
......@@ -244,8 +244,8 @@ gfx::Size BridgedNativeWidgetImpl::GetWindowSizeForClientSize(
// static
BridgedNativeWidgetImpl* BridgedNativeWidgetImpl::GetFromId(
uint64_t bridged_native_widget_id) {
auto found = g_id_to_impl_map.get()->find(bridged_native_widget_id);
if (found == g_id_to_impl_map.get()->end())
auto found = g_id_map.get()->find(bridged_native_widget_id);
if (found == g_id_map.get()->end())
return nullptr;
return found->second;
}
......@@ -259,17 +259,17 @@ BridgedNativeWidgetImpl::BridgedNativeWidgetImpl(
host_(host),
host_helper_(host_helper),
native_widget_mac_(parent) {
DCHECK(g_id_to_impl_map.get()->find(id_) == g_id_to_impl_map.get()->end());
g_id_to_impl_map.get()->insert(std::make_pair(id_, this));
DCHECK(g_id_map.get()->find(id_) == g_id_map.get()->end());
g_id_map.get()->insert(std::make_pair(id_, this));
DCHECK(parent);
}
BridgedNativeWidgetImpl::~BridgedNativeWidgetImpl() {
// Ensure that |this| cannot be reached by its id while it is being destroyed.
auto found = g_id_to_impl_map.get()->find(id_);
DCHECK(found != g_id_to_impl_map.get()->end());
auto found = g_id_map.get()->find(id_);
DCHECK(found != g_id_map.get()->end());
DCHECK_EQ(found->second, this);
g_id_to_impl_map.get()->erase(found);
g_id_map.get()->erase(found);
// The delegate should be cleared already. Note this enforces the precondition
// that -[NSWindow close] is invoked on the hosted window before the
......
......@@ -41,8 +41,7 @@ bool PositionWindowInScreenCoordinates(Widget* widget,
return widget && widget->is_top_level();
}
base::NoDestructor<std::map<uint64_t, BridgedNativeWidgetHostImpl*>>
g_id_to_host_impl_map;
base::NoDestructor<std::map<uint64_t, BridgedNativeWidgetHostImpl*>> g_id_map;
uint64_t g_last_bridged_native_widget_id = 0;
......@@ -51,8 +50,8 @@ uint64_t g_last_bridged_native_widget_id = 0;
// static
BridgedNativeWidgetHostImpl* BridgedNativeWidgetHostImpl::GetFromId(
uint64_t bridged_native_widget_id) {
auto found = g_id_to_host_impl_map.get()->find(bridged_native_widget_id);
if (found == g_id_to_host_impl_map.get()->end())
auto found = g_id_map.get()->find(bridged_native_widget_id);
if (found == g_id_map.get()->end())
return nullptr;
return found->second;
}
......@@ -62,18 +61,17 @@ BridgedNativeWidgetHostImpl::BridgedNativeWidgetHostImpl(
: id_(++g_last_bridged_native_widget_id),
native_widget_mac_(parent),
bridge_impl_(new BridgedNativeWidgetImpl(id_, this, this, parent)) {
DCHECK(g_id_to_host_impl_map.get()->find(id_) ==
g_id_to_host_impl_map.get()->end());
g_id_to_host_impl_map.get()->insert(std::make_pair(id_, this));
DCHECK(g_id_map.get()->find(id_) == g_id_map.get()->end());
g_id_map.get()->insert(std::make_pair(id_, this));
DCHECK(parent);
}
BridgedNativeWidgetHostImpl::~BridgedNativeWidgetHostImpl() {
// Ensure that |this| cannot be reached by its id while it is being destroyed.
auto found = g_id_to_host_impl_map.get()->find(id_);
DCHECK(found != g_id_to_host_impl_map.get()->end());
auto found = g_id_map.get()->find(id_);
DCHECK(found != g_id_map.get()->end());
DCHECK_EQ(found->second, this);
g_id_to_host_impl_map.get()->erase(found);
g_id_map.get()->erase(found);
// Destroy the bridge first to prevent any calls back into this during
// destruction.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment