| OLD | NEW |
| 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/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/threading/thread_local.h" | 8 #include "base/threading/thread_local.h" |
| 9 #include "ui/aura/env_observer.h" | 9 #include "ui/aura/env_observer.h" |
| 10 #include "ui/aura/input_state_lookup.h" | 10 #include "ui/aura/input_state_lookup.h" |
| 11 #include "ui/events/event_target_iterator.h" | 11 #include "ui/events/event_target_iterator.h" |
| 12 #include "ui/events/platform/platform_event_source.h" | 12 #include "ui/events/platform/platform_event_source.h" |
| 13 | 13 |
| 14 #if defined(USE_OZONE) |
| 15 #include "ui/ozone/ozone_platform.h" |
| 16 #endif |
| 17 |
| 14 namespace aura { | 18 namespace aura { |
| 15 | 19 |
| 16 namespace { | 20 namespace { |
| 17 | 21 |
| 18 // Env is thread local so that aura may be used on multiple threads. | 22 // Env is thread local so that aura may be used on multiple threads. |
| 19 base::LazyInstance<base::ThreadLocalPointer<Env> >::Leaky lazy_tls_ptr = | 23 base::LazyInstance<base::ThreadLocalPointer<Env> >::Leaky lazy_tls_ptr = |
| 20 LAZY_INSTANCE_INITIALIZER; | 24 LAZY_INSTANCE_INITIALIZER; |
| 21 | 25 |
| 22 } // namespace | 26 } // namespace |
| 23 | 27 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 lazy_tls_ptr.Pointer()->Set(this); | 71 lazy_tls_ptr.Pointer()->Set(this); |
| 68 } | 72 } |
| 69 | 73 |
| 70 Env::~Env() { | 74 Env::~Env() { |
| 71 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWillDestroyEnv()); | 75 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWillDestroyEnv()); |
| 72 DCHECK_EQ(this, lazy_tls_ptr.Pointer()->Get()); | 76 DCHECK_EQ(this, lazy_tls_ptr.Pointer()->Get()); |
| 73 lazy_tls_ptr.Pointer()->Set(NULL); | 77 lazy_tls_ptr.Pointer()->Set(NULL); |
| 74 } | 78 } |
| 75 | 79 |
| 76 void Env::Init(bool create_event_source) { | 80 void Env::Init(bool create_event_source) { |
| 81 #if defined(USE_OZONE) |
| 82 // The ozone platform can provide its own event source. So initialize the |
| 83 // platform before creating the default event source. |
| 84 ui::OzonePlatform::InitializeForUI(); |
| 85 #endif |
| 77 if (create_event_source && !ui::PlatformEventSource::GetInstance()) | 86 if (create_event_source && !ui::PlatformEventSource::GetInstance()) |
| 78 event_source_ = ui::PlatformEventSource::CreateDefault(); | 87 event_source_ = ui::PlatformEventSource::CreateDefault(); |
| 79 } | 88 } |
| 80 | 89 |
| 81 void Env::NotifyWindowInitialized(Window* window) { | 90 void Env::NotifyWindowInitialized(Window* window) { |
| 82 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWindowInitialized(window)); | 91 FOR_EACH_OBSERVER(EnvObserver, observers_, OnWindowInitialized(window)); |
| 83 } | 92 } |
| 84 | 93 |
| 85 void Env::NotifyHostInitialized(WindowTreeHost* host) { | 94 void Env::NotifyHostInitialized(WindowTreeHost* host) { |
| 86 FOR_EACH_OBSERVER(EnvObserver, observers_, OnHostInitialized(host)); | 95 FOR_EACH_OBSERVER(EnvObserver, observers_, OnHostInitialized(host)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 104 scoped_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { | 113 scoped_ptr<ui::EventTargetIterator> Env::GetChildIterator() const { |
| 105 return scoped_ptr<ui::EventTargetIterator>(); | 114 return scoped_ptr<ui::EventTargetIterator>(); |
| 106 } | 115 } |
| 107 | 116 |
| 108 ui::EventTargeter* Env::GetEventTargeter() { | 117 ui::EventTargeter* Env::GetEventTargeter() { |
| 109 NOTREACHED(); | 118 NOTREACHED(); |
| 110 return NULL; | 119 return NULL; |
| 111 } | 120 } |
| 112 | 121 |
| 113 } // namespace aura | 122 } // namespace aura |
| OLD | NEW |