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

Unified Diff: ui/aura/window_id_registry.h

Issue 100603002: Add aura::WindowIdRegistry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | « ui/aura/aura.gyp ('k') | ui/aura/window_id_registry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/window_id_registry.h
diff --git a/ui/aura/window_id_registry.h b/ui/aura/window_id_registry.h
new file mode 100644
index 0000000000000000000000000000000000000000..595bc865eec1e91aff198a1dbab67b9cfbbea791
--- /dev/null
+++ b/ui/aura/window_id_registry.h
@@ -0,0 +1,48 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_AURA_WINDOW_ID_REGISTRY_H_
+#define UI_AURA_WINDOW_ID_REGISTRY_H_
+
+#include <map>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/singleton.h"
+#include "ui/aura/aura_export.h"
+#include "ui/aura/window_observer.h"
+
+namespace aura {
+
+// WindowIdRegistry assigns unique identifiers to Aura windows.
+class AURA_EXPORT WindowIdRegistry : public WindowObserver {
+ public:
+ static WindowIdRegistry* GetInstance();
+
+ // Returns unique Id for |window|. New Id is allocated when this method is
+ // called for the |window| for the first time.
+ int GetIdForWindow(Window* window);
+
+ // Returns window with the specified |id|. NULL is returned if the |id| is
+ // invalid or the window it refers to was destroyed.
+ Window* GetWindowById(int id);
+
+ private:
+ friend struct DefaultSingletonTraits<WindowIdRegistry>;
+ WindowIdRegistry();
+ virtual ~WindowIdRegistry();
+
+ // WindowObserver overrides.
+ virtual void OnWindowDestroying(Window* window) OVERRIDE;
+
+ int next_id_;
+ std::map<Window*, int> window_to_id_map_;
+ std::map<int, Window*> id_to_window_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(WindowIdRegistry);
+};
+
+} // namespace aura
+
+#endif // UI_AURA_WINDOW_ID_REGISTRY_H_
« no previous file with comments | « ui/aura/aura.gyp ('k') | ui/aura/window_id_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698