Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / content / public / browser / desktop_media_id.cc
index a2adfda..18b0955 100644 (file)
@@ -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() {}