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

Side by Side Diff: ui/aura/env.cc

Issue 2422073002: Reduce FOR_EACH_OBSERVER usage in ui/ (Closed)
Patch Set: remove space Created 4 years, 2 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/android/window_android.cc ('k') | ui/aura/test/test_cursor_client.cc » ('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/aura/env.h" 5 #include "ui/aura/env.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/threading/thread_local.h" 9 #include "base/threading/thread_local.h"
10 #include "ui/aura/env_observer.h" 10 #include "ui/aura/env_observer.h"
(...skipping 18 matching lines...) Expand all
29 return base::CommandLine::ForCurrentProcess()->HasSwitch( 29 return base::CommandLine::ForCurrentProcess()->HasSwitch(
30 "primordial-pipe-token"); 30 "primordial-pipe-token");
31 } 31 }
32 32
33 } // namespace 33 } // namespace
34 34
35 //////////////////////////////////////////////////////////////////////////////// 35 ////////////////////////////////////////////////////////////////////////////////
36 // Env, public: 36 // Env, public:
37 37
38 Env::~Env() { 38 Env::~Env() {
39 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWillDestroyEnv()); 39 for (EnvObserver& observer : observers_)
40 observer.OnWillDestroyEnv();
40 DCHECK_EQ(this, lazy_tls_ptr.Pointer()->Get()); 41 DCHECK_EQ(this, lazy_tls_ptr.Pointer()->Get());
41 lazy_tls_ptr.Pointer()->Set(NULL); 42 lazy_tls_ptr.Pointer()->Set(NULL);
42 } 43 }
43 44
44 // static 45 // static
45 std::unique_ptr<Env> Env::CreateInstance() { 46 std::unique_ptr<Env> Env::CreateInstance() {
46 DCHECK(!lazy_tls_ptr.Pointer()->Get()); 47 DCHECK(!lazy_tls_ptr.Pointer()->Get());
47 std::unique_ptr<Env> env(new Env()); 48 std::unique_ptr<Env> env(new Env());
48 env->Init(); 49 env->Init();
49 return env; 50 return env;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // The ozone platform can provide its own event source. So initialize the 95 // The ozone platform can provide its own event source. So initialize the
95 // platform before creating the default event source. If running inside mus 96 // platform before creating the default event source. If running inside mus
96 // let the mus process initialize ozone instead. 97 // let the mus process initialize ozone instead.
97 ui::OzonePlatform::InitializeForUI(); 98 ui::OzonePlatform::InitializeForUI();
98 #endif 99 #endif
99 if (!ui::PlatformEventSource::GetInstance()) 100 if (!ui::PlatformEventSource::GetInstance())
100 event_source_ = ui::PlatformEventSource::CreateDefault(); 101 event_source_ = ui::PlatformEventSource::CreateDefault();
101 } 102 }
102 103
103 void Env::NotifyWindowInitialized(Window* window) { 104 void Env::NotifyWindowInitialized(Window* window) {
104 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWindowInitialized(window)); 105 for (EnvObserver& observer : observers_)
106 observer.OnWindowInitialized(window);
105 } 107 }
106 108
107 void Env::NotifyHostInitialized(WindowTreeHost* host) { 109 void Env::NotifyHostInitialized(WindowTreeHost* host) {
108 FOR_EACH_OBSERVER(EnvObserver, observers_, OnHostInitialized(host)); 110 for (EnvObserver& observer : observers_)
111 observer.OnHostInitialized(host);
109 } 112 }
110 113
111 void Env::NotifyHostActivated(WindowTreeHost* host) { 114 void Env::NotifyHostActivated(WindowTreeHost* host) {
112 FOR_EACH_OBSERVER(EnvObserver, observers_, OnHostActivated(host)); 115 for (EnvObserver& observer : observers_)
116 observer.OnHostActivated(host);
113 } 117 }
114 118
115 //////////////////////////////////////////////////////////////////////////////// 119 ////////////////////////////////////////////////////////////////////////////////
116 // Env, ui::EventTarget implementation: 120 // Env, ui::EventTarget implementation:
117 121
118 bool Env::CanAcceptEvent(const ui::Event& event) { 122 bool Env::CanAcceptEvent(const ui::Event& event) {
119 return true; 123 return true;
120 } 124 }
121 125
122 ui::EventTarget* Env::GetParentTarget() { 126 ui::EventTarget* Env::GetParentTarget() {
123 return NULL; 127 return NULL;
124 } 128 }
125 129
126 std::unique_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { 130 std::unique_ptr<ui::EventTargetIterator> Env::GetChildIterator() const {
127 return nullptr; 131 return nullptr;
128 } 132 }
129 133
130 ui::EventTargeter* Env::GetEventTargeter() { 134 ui::EventTargeter* Env::GetEventTargeter() {
131 NOTREACHED(); 135 NOTREACHED();
132 return NULL; 136 return NULL;
133 } 137 }
134 138
135 } // namespace aura 139 } // namespace aura
OLDNEW
« no previous file with comments | « ui/android/window_android.cc ('k') | ui/aura/test/test_cursor_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698