Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Unified Diff: content/public/browser/desktop_media_id.cc

Issue 499813002: Update AuraWindowRegistry to create only positive window IDs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698