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

Side by Side Diff: ui/base/win/hwnd_subclass.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
« no previous file with comments | « ui/base/ime/input_method_auralinux_unittest.cc ('k') | ui/base/x/x11_foreign_window_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/base/win/hwnd_subclass.h" 5 #include "ui/base/win/hwnd_subclass.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 } // namespace 49 } // namespace
50 50
51 namespace ui { 51 namespace ui {
52 52
53 // Singleton factory that creates and manages the lifetime of all 53 // Singleton factory that creates and manages the lifetime of all
54 // ui::HWNDSubclass objects. 54 // ui::HWNDSubclass objects.
55 class HWNDSubclass::HWNDSubclassFactory { 55 class HWNDSubclass::HWNDSubclassFactory {
56 public: 56 public:
57 static HWNDSubclassFactory* GetInstance() { 57 static HWNDSubclassFactory* GetInstance() {
58 return Singleton<HWNDSubclassFactory, 58 return base::Singleton<
59 LeakySingletonTraits<HWNDSubclassFactory> >::get(); 59 HWNDSubclassFactory,
60 base::LeakySingletonTraits<HWNDSubclassFactory>>::get();
60 } 61 }
61 62
62 // Returns a non-null HWNDSubclass corresponding to the HWND |target|. Creates 63 // Returns a non-null HWNDSubclass corresponding to the HWND |target|. Creates
63 // one if none exists. Retains ownership of the returned pointer. 64 // one if none exists. Retains ownership of the returned pointer.
64 HWNDSubclass* GetHwndSubclassForTarget(HWND target) { 65 HWNDSubclass* GetHwndSubclassForTarget(HWND target) {
65 DCHECK(target); 66 DCHECK(target);
66 HWNDSubclass* subclass = reinterpret_cast<HWNDSubclass*>( 67 HWNDSubclass* subclass = reinterpret_cast<HWNDSubclass*>(
67 ui::ViewProp::GetValue(target, kHWNDSubclassKey)); 68 ui::ViewProp::GetValue(target, kHWNDSubclassKey));
68 if (!subclass) { 69 if (!subclass) {
69 subclass = new ui::HWNDSubclass(target); 70 subclass = new ui::HWNDSubclass(target);
70 hwnd_subclasses_.push_back(subclass); 71 hwnd_subclasses_.push_back(subclass);
71 } 72 }
72 return subclass; 73 return subclass;
73 } 74 }
74 75
75 const ScopedVector<HWNDSubclass>& hwnd_subclasses() { 76 const ScopedVector<HWNDSubclass>& hwnd_subclasses() {
76 return hwnd_subclasses_; 77 return hwnd_subclasses_;
77 } 78 }
78 79
79 private: 80 private:
80 friend struct DefaultSingletonTraits<HWNDSubclassFactory>; 81 friend struct base::DefaultSingletonTraits<HWNDSubclassFactory>;
81 82
82 HWNDSubclassFactory() {} 83 HWNDSubclassFactory() {}
83 84
84 ScopedVector<HWNDSubclass> hwnd_subclasses_; 85 ScopedVector<HWNDSubclass> hwnd_subclasses_;
85 86
86 DISALLOW_COPY_AND_ASSIGN(HWNDSubclassFactory); 87 DISALLOW_COPY_AND_ASSIGN(HWNDSubclassFactory);
87 }; 88 };
88 89
89 // static 90 // static
90 void HWNDSubclass::AddFilterToTarget(HWND target, HWNDMessageFilter* filter) { 91 void HWNDSubclass::AddFilterToTarget(HWND target, HWNDMessageFilter* filter) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // In most cases, |original_wnd_proc_| will take care of calling 162 // In most cases, |original_wnd_proc_| will take care of calling
162 // DefWindowProc. 163 // DefWindowProc.
163 return CallWindowProc(original_wnd_proc_, hwnd, message, w_param, l_param); 164 return CallWindowProc(original_wnd_proc_, hwnd, message, w_param, l_param);
164 } 165 }
165 166
166 HWNDMessageFilter::~HWNDMessageFilter() { 167 HWNDMessageFilter::~HWNDMessageFilter() {
167 HWNDSubclass::RemoveFilterFromAllTargets(this); 168 HWNDSubclass::RemoveFilterFromAllTargets(this);
168 } 169 }
169 170
170 } // namespace ui 171 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_auralinux_unittest.cc ('k') | ui/base/x/x11_foreign_window_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698