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

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

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 #include "chrome/browser/ui/libgtk2ui/g_object_destructor_filo.h" 5 #include "chrome/browser/ui/libgtk2ui/g_object_destructor_filo.h"
6 6
7 #include <glib-object.h> 7 #include <glib-object.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
11 11
12 namespace libgtk2ui { 12 namespace libgtk2ui {
13 13
14 GObjectDestructorFILO::GObjectDestructorFILO() { 14 GObjectDestructorFILO::GObjectDestructorFILO() {
15 } 15 }
16 16
17 GObjectDestructorFILO::~GObjectDestructorFILO() { 17 GObjectDestructorFILO::~GObjectDestructorFILO() {
18 // Probably CHECK(handler_map_.empty()) would look natural here. But 18 // Probably CHECK(handler_map_.empty()) would look natural here. But
19 // some tests (some views_unittests) violate this assertion. 19 // some tests (some views_unittests) violate this assertion.
20 } 20 }
21 21
22 // static 22 // static
23 GObjectDestructorFILO* GObjectDestructorFILO::GetInstance() { 23 GObjectDestructorFILO* GObjectDestructorFILO::GetInstance() {
24 return Singleton<GObjectDestructorFILO>::get(); 24 return base::Singleton<GObjectDestructorFILO>::get();
25 } 25 }
26 26
27 void GObjectDestructorFILO::Connect( 27 void GObjectDestructorFILO::Connect(
28 GObject* object, DestructorHook callback, void* context) { 28 GObject* object, DestructorHook callback, void* context) {
29 const Hook hook(object, callback, context); 29 const Hook hook(object, callback, context);
30 HandlerMap::iterator iter = handler_map_.find(object); 30 HandlerMap::iterator iter = handler_map_.find(object);
31 if (iter == handler_map_.end()) { 31 if (iter == handler_map_.end()) {
32 g_object_weak_ref(object, WeakNotifyThunk, this); 32 g_object_weak_ref(object, WeakNotifyThunk, this);
33 handler_map_[object].push_front(hook); 33 handler_map_[object].push_front(hook);
34 } else { 34 } else {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 HandlerList dtors; 80 HandlerList dtors;
81 iter->second.swap(dtors); 81 iter->second.swap(dtors);
82 handler_map_.erase(iter); 82 handler_map_.erase(iter);
83 83
84 // Execute hooks in local list in FILO order. 84 // Execute hooks in local list in FILO order.
85 for (HandlerList::iterator i = dtors.begin(); i != dtors.end(); ++i) 85 for (HandlerList::iterator i = dtors.begin(); i != dtors.end(); ++i)
86 i->callback(i->context, where_the_object_was); 86 i->callback(i->context, where_the_object_was);
87 } 87 }
88 88
89 } // namespace libgtk2ui 89 } // namespace libgtk2ui
OLDNEW
« no previous file with comments | « chrome/browser/ui/libgtk2ui/g_object_destructor_filo.h ('k') | chrome/browser/ui/libgtk2ui/gtk2_event_loop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698