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) { ...@@ -226,7 +226,7 @@ NSUInteger CountBridgedWindows(NSArray* child_windows) {
return count; return count;
} }
std::map<uint64_t, BridgedNativeWidgetImpl*>& GetIdMap() { std::map<uint64_t, BridgedNativeWidgetImpl*>& GetIdToWidgetImplMap() {
static base::NoDestructor<std::map<uint64_t, BridgedNativeWidgetImpl*>> static base::NoDestructor<std::map<uint64_t, BridgedNativeWidgetImpl*>>
id_map; id_map;
return *id_map; return *id_map;
...@@ -247,8 +247,8 @@ gfx::Size BridgedNativeWidgetImpl::GetWindowSizeForClientSize( ...@@ -247,8 +247,8 @@ gfx::Size BridgedNativeWidgetImpl::GetWindowSizeForClientSize(
// static // static
BridgedNativeWidgetImpl* BridgedNativeWidgetImpl::GetFromId( BridgedNativeWidgetImpl* BridgedNativeWidgetImpl::GetFromId(
uint64_t bridged_native_widget_id) { uint64_t bridged_native_widget_id) {
auto found = GetIdMap().find(bridged_native_widget_id); auto found = GetIdToWidgetImplMap().find(bridged_native_widget_id);
if (found == GetIdMap().end()) if (found == GetIdToWidgetImplMap().end())
return nullptr; return nullptr;
return found->second; return found->second;
} }
...@@ -262,17 +262,17 @@ BridgedNativeWidgetImpl::BridgedNativeWidgetImpl( ...@@ -262,17 +262,17 @@ BridgedNativeWidgetImpl::BridgedNativeWidgetImpl(
host_(host), host_(host),
host_helper_(host_helper), host_helper_(host_helper),
native_widget_mac_(parent) { native_widget_mac_(parent) {
DCHECK(GetIdMap().find(id_) == GetIdMap().end()); DCHECK(GetIdToWidgetImplMap().find(id_) == GetIdToWidgetImplMap().end());
GetIdMap().insert(std::make_pair(id_, this)); GetIdToWidgetImplMap().insert(std::make_pair(id_, this));
DCHECK(parent); DCHECK(parent);
} }
BridgedNativeWidgetImpl::~BridgedNativeWidgetImpl() { BridgedNativeWidgetImpl::~BridgedNativeWidgetImpl() {
// Ensure that |this| cannot be reached by its id while it is being destroyed. // Ensure that |this| cannot be reached by its id while it is being destroyed.
auto found = GetIdMap().find(id_); auto found = GetIdToWidgetImplMap().find(id_);
DCHECK(found != GetIdMap().end()); DCHECK(found != GetIdToWidgetImplMap().end());
DCHECK_EQ(found->second, this); DCHECK_EQ(found->second, this);
GetIdMap().erase(found); GetIdToWidgetImplMap().erase(found);
// The delegate should be cleared already. Note this enforces the precondition // The delegate should be cleared already. Note this enforces the precondition
// that -[NSWindow close] is invoked on the hosted window before the // that -[NSWindow close] is invoked on the hosted window before the
......
...@@ -41,7 +41,7 @@ bool PositionWindowInScreenCoordinates(Widget* widget, ...@@ -41,7 +41,7 @@ bool PositionWindowInScreenCoordinates(Widget* widget,
return widget && widget->is_top_level(); 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*>> static base::NoDestructor<std::map<uint64_t, BridgedNativeWidgetHostImpl*>>
id_map; id_map;
return *id_map; return *id_map;
...@@ -54,8 +54,8 @@ uint64_t g_last_bridged_native_widget_id = 0; ...@@ -54,8 +54,8 @@ uint64_t g_last_bridged_native_widget_id = 0;
// static // static
BridgedNativeWidgetHostImpl* BridgedNativeWidgetHostImpl::GetFromId( BridgedNativeWidgetHostImpl* BridgedNativeWidgetHostImpl::GetFromId(
uint64_t bridged_native_widget_id) { uint64_t bridged_native_widget_id) {
auto found = GetIdMap().find(bridged_native_widget_id); auto found = GetIdToWidgetHostImplMap().find(bridged_native_widget_id);
if (found == GetIdMap().end()) if (found == GetIdToWidgetHostImplMap().end())
return nullptr; return nullptr;
return found->second; return found->second;
} }
...@@ -65,17 +65,18 @@ BridgedNativeWidgetHostImpl::BridgedNativeWidgetHostImpl( ...@@ -65,17 +65,18 @@ BridgedNativeWidgetHostImpl::BridgedNativeWidgetHostImpl(
: id_(++g_last_bridged_native_widget_id), : id_(++g_last_bridged_native_widget_id),
native_widget_mac_(parent), native_widget_mac_(parent),
bridge_impl_(new BridgedNativeWidgetImpl(id_, this, this, parent)) { bridge_impl_(new BridgedNativeWidgetImpl(id_, this, this, parent)) {
DCHECK(GetIdMap().find(id_) == GetIdMap().end()); DCHECK(GetIdToWidgetHostImplMap().find(id_) ==
GetIdMap().insert(std::make_pair(id_, this)); GetIdToWidgetHostImplMap().end());
GetIdToWidgetHostImplMap().insert(std::make_pair(id_, this));
DCHECK(parent); DCHECK(parent);
} }
BridgedNativeWidgetHostImpl::~BridgedNativeWidgetHostImpl() { BridgedNativeWidgetHostImpl::~BridgedNativeWidgetHostImpl() {
// Ensure that |this| cannot be reached by its id while it is being destroyed. // Ensure that |this| cannot be reached by its id while it is being destroyed.
auto found = GetIdMap().find(id_); auto found = GetIdToWidgetHostImplMap().find(id_);
DCHECK(found != GetIdMap().end()); DCHECK(found != GetIdToWidgetHostImplMap().end());
DCHECK_EQ(found->second, this); DCHECK_EQ(found->second, this);
GetIdMap().erase(found); GetIdToWidgetHostImplMap().erase(found);
// Destroy the bridge first to prevent any calls back into this during // Destroy the bridge first to prevent any calls back into this during
// destruction. // 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