Commit fc74c509 authored by sergeyu's avatar sergeyu Committed by Commit bot

Update AuraWindowRegistry to create only positive window IDs.

Previously AuraWindowRegistry was allocating ID 0 to first window. This
breaks assumptions made in other places, e.g. DCHECK in
DesktopMediaPickerDialogView. After this change the implementation
guarantees that window IDs are always unique positive integers.

Review URL: https://codereview.chromium.org/499813002

Cr-Commit-Position: refs/heads/master@{#291708}
parent 31e24d29
......@@ -32,7 +32,12 @@ class AuraWindowRegistry : public aura::WindowObserver {
}
// If the windows doesn't have an Id yet assign it.
int id = next_id_++;
int id;
do {
id = next_id_;
next_id_ = (next_id_ == INT_MAX) ? 1 : (next_id_ + 1);
} while (id_to_window_map_.find(id) != id_to_window_map_.end());
window_to_id_map_[window] = id;
id_to_window_map_[id] = window;
window->AddObserver(this);
......@@ -48,7 +53,7 @@ class AuraWindowRegistry : public aura::WindowObserver {
friend struct DefaultSingletonTraits<AuraWindowRegistry>;
AuraWindowRegistry()
: next_id_(0) {
: next_id_(1) {
}
virtual ~AuraWindowRegistry() {}
......
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