Index: content/public/browser/desktop_media_id.cc |
diff --git a/content/public/browser/desktop_media_id.cc b/content/public/browser/desktop_media_id.cc |
index a2adfdab5e604ccaa5e89ca39e29b378d7a5e7cc..18b095599f16d6744064376bd76ca2f6bb7c2b46 100644 |
--- a/content/public/browser/desktop_media_id.cc |
+++ b/content/public/browser/desktop_media_id.cc |
@@ -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() {} |