Commit dc72e09f authored by Daniel Bratell's avatar Daniel Bratell Committed by Commit Bot

[jumbo] Make it one GetIdMap() instead of two.

A commit just introduced two GetIdMap functions in ui/views/cocoa,
which broke jumbo builds because in jumbo builds they end up in
the same translation unit. This patch renames them
GetIdToWidgetImplMap and GetIdToWidgetHostImplMap

Bug: 859152

TBR=ccameron@chromium.org,ellyjones@chromium.org

Change-Id: I55b4a48d3d4f97c30450fd89bb8f52f46c2cedd7
Reviewed-on: https://chromium-review.googlesource.com/1219127Reviewed-by: default avatarDaniel Bratell <bratell@opera.com>
Commit-Queue: Daniel Bratell <bratell@opera.com>
Cr-Commit-Position: refs/heads/master@{#590257}
parent 4574eb06
......@@ -226,7 +226,7 @@ NSUInteger CountBridgedWindows(NSArray* child_windows) {
return count;
}
std::map<uint64_t, BridgedNativeWidgetImpl*>& GetIdMap() {
std::map<uint64_t, BridgedNativeWidgetImpl*>& GetIdToWidgetImplMap() {
static base::NoDestructor<std::map<uint64_t, BridgedNativeWidgetImpl*>>
id_map;
return *id_map;
......@@ -247,8 +247,8 @@ gfx::Size BridgedNativeWidgetImpl::GetWindowSizeForClientSize(
// static
BridgedNativeWidgetImpl* BridgedNativeWidgetImpl::GetFromId(
uint64_t bridged_native_widget_id) {
auto found = GetIdMap().find(bridged_native_widget_id);
if (found == GetIdMap().end())
auto found = GetIdToWidgetImplMap().find(bridged_native_widget_id);
if (found == GetIdToWidgetImplMap().end())
return nullptr;
return found->second;
}
......@@ -262,17 +262,17 @@ BridgedNativeWidgetImpl::BridgedNativeWidgetImpl(
host_(host),
host_helper_(host_helper),
native_widget_mac_(parent) {
DCHECK(GetIdMap().find(id_) == GetIdMap().end());
GetIdMap().insert(std::make_pair(id_, this));
DCHECK(GetIdToWidgetImplMap().find(id_) == GetIdToWidgetImplMap().end());
GetIdToWidgetImplMap().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 = GetIdMap().find(id_);
DCHECK(found != GetIdMap().end());
auto found = GetIdToWidgetImplMap().find(id_);
DCHECK(found != GetIdToWidgetImplMap().end());
DCHECK_EQ(found->second, this);
GetIdMap().erase(found);
GetIdToWidgetImplMap().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,7 +41,7 @@ bool PositionWindowInScreenCoordinates(Widget* widget,
return widget && widget->is_top_level();
}
std::map<uint64_t, BridgedNativeWidgetHostImpl*>& GetIdMap() {
std::map<uint64_t, BridgedNativeWidgetHostImpl*>& GetIdToWidgetHostImplMap() {
static base::NoDestructor<std::map<uint64_t, BridgedNativeWidgetHostImpl*>>
id_map;
return *id_map;
......@@ -54,8 +54,8 @@ uint64_t g_last_bridged_native_widget_id = 0;
// static
BridgedNativeWidgetHostImpl* BridgedNativeWidgetHostImpl::GetFromId(
uint64_t bridged_native_widget_id) {
auto found = GetIdMap().find(bridged_native_widget_id);
if (found == GetIdMap().end())
auto found = GetIdToWidgetHostImplMap().find(bridged_native_widget_id);
if (found == GetIdToWidgetHostImplMap().end())
return nullptr;
return found->second;
}
......@@ -65,17 +65,18 @@ BridgedNativeWidgetHostImpl::BridgedNativeWidgetHostImpl(
: id_(++g_last_bridged_native_widget_id),
native_widget_mac_(parent),
bridge_impl_(new BridgedNativeWidgetImpl(id_, this, this, parent)) {
DCHECK(GetIdMap().find(id_) == GetIdMap().end());
GetIdMap().insert(std::make_pair(id_, this));
DCHECK(GetIdToWidgetHostImplMap().find(id_) ==
GetIdToWidgetHostImplMap().end());
GetIdToWidgetHostImplMap().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 = GetIdMap().find(id_);
DCHECK(found != GetIdMap().end());
auto found = GetIdToWidgetHostImplMap().find(id_);
DCHECK(found != GetIdToWidgetHostImplMap().end());
DCHECK_EQ(found->second, this);
GetIdMap().erase(found);
GetIdToWidgetHostImplMap().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