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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/aura.gyp ('k') | ui/aura/window_id_registry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_AURA_WINDOW_ID_REGISTRY_H_
6 #define UI_AURA_WINDOW_ID_REGISTRY_H_
7
8 #include <map>
9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/singleton.h"
13 #include "ui/aura/aura_export.h"
14 #include "ui/aura/window_observer.h"
15
16 namespace aura {
17
18 // WindowIdRegistry assigns unique identifiers to Aura windows.
19 class AURA_EXPORT WindowIdRegistry : public WindowObserver {
20 public:
21 static WindowIdRegistry* GetInstance();
22
23 // Returns unique Id for |window|. New Id is allocated when this method is
24 // called for the |window| for the first time.
25 int GetIdForWindow(Window* window);
26
27 // Returns window with the specified |id|. NULL is returned if the |id| is
28 // invalid or the window it refers to was destroyed.
29 Window* GetWindowById(int id);
30
31 private:
32 friend struct DefaultSingletonTraits<WindowIdRegistry>;
33 WindowIdRegistry();
34 virtual ~WindowIdRegistry();
35
36 // WindowObserver overrides.
37 virtual void OnWindowDestroying(Window* window) OVERRIDE;
38
39 int next_id_;
40 std::map<Window*, int> window_to_id_map_;
41 std::map<int, Window*> id_to_window_map_;
42
43 DISALLOW_COPY_AND_ASSIGN(WindowIdRegistry);
44 };
45
46 } // namespace aura
47
48 #endif // UI_AURA_WINDOW_ID_REGISTRY_H_
OLDNEW
« 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