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

Side by Side Diff: chrome/browser/ui/libgtk2ui/g_object_destructor_filo.h

Issue 1308823002: Move Singleton and related structs to namespace base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ToT Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_G_OBJECT_DESTRUCTOR_FILO_H_ 5 #ifndef CHROME_BROWSER_UI_LIBGTK2UI_G_OBJECT_DESTRUCTOR_FILO_H_
6 #define CHROME_BROWSER_UI_LIBGTK2UI_G_OBJECT_DESTRUCTOR_FILO_H_ 6 #define CHROME_BROWSER_UI_LIBGTK2UI_G_OBJECT_DESTRUCTOR_FILO_H_
7 7
8 #include <glib.h> 8 #include <glib.h>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 13
14 namespace base {
14 template <typename T> struct DefaultSingletonTraits; 15 template <typename T> struct DefaultSingletonTraits;
16 }
15 17
16 typedef struct _GObject GObject; 18 typedef struct _GObject GObject;
17 19
18 namespace libgtk2ui { 20 namespace libgtk2ui {
19 21
20 // This class hooks calls to g_object_weak_ref()/unref() and executes them in 22 // This class hooks calls to g_object_weak_ref()/unref() and executes them in
21 // FILO order. This is important if there are several hooks to the single object 23 // FILO order. This is important if there are several hooks to the single object
22 // (set up at different levels of class hierarchy) and the lowest hook (set up 24 // (set up at different levels of class hierarchy) and the lowest hook (set up
23 // first) is deleting self - it must be called last (among hooks for the given 25 // first) is deleting self - it must be called last (among hooks for the given
24 // object). Unfortunately Glib does not provide this guarantee. 26 // object). Unfortunately Glib does not provide this guarantee.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 67 }
66 GObject* object; 68 GObject* object;
67 DestructorHook callback; 69 DestructorHook callback;
68 void* context; 70 void* context;
69 }; 71 };
70 typedef std::list<Hook> HandlerList; 72 typedef std::list<Hook> HandlerList;
71 typedef std::map<GObject*, HandlerList> HandlerMap; 73 typedef std::map<GObject*, HandlerList> HandlerMap;
72 74
73 GObjectDestructorFILO(); 75 GObjectDestructorFILO();
74 ~GObjectDestructorFILO(); 76 ~GObjectDestructorFILO();
75 friend struct DefaultSingletonTraits<GObjectDestructorFILO>; 77 friend struct base::DefaultSingletonTraits<GObjectDestructorFILO>;
76 78
77 void WeakNotify(GObject* where_the_object_was); 79 void WeakNotify(GObject* where_the_object_was);
78 static void WeakNotifyThunk(gpointer data, GObject* where_the_object_was) { 80 static void WeakNotifyThunk(gpointer data, GObject* where_the_object_was) {
79 reinterpret_cast<GObjectDestructorFILO*>(data)->WeakNotify( 81 reinterpret_cast<GObjectDestructorFILO*>(data)->WeakNotify(
80 where_the_object_was); 82 where_the_object_was);
81 } 83 }
82 84
83 HandlerMap handler_map_; 85 HandlerMap handler_map_;
84 86
85 DISALLOW_COPY_AND_ASSIGN(GObjectDestructorFILO); 87 DISALLOW_COPY_AND_ASSIGN(GObjectDestructorFILO);
86 }; 88 };
87 89
88 } // namespace libgtk2ui 90 } // namespace libgtk2ui
89 91
90 #endif // CHROME_BROWSER_UI_LIBGTK2UI_G_OBJECT_DESTRUCTOR_FILO_H_ 92 #endif // CHROME_BROWSER_UI_LIBGTK2UI_G_OBJECT_DESTRUCTOR_FILO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698