OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 UI_OZONE_PUBLIC_OZONE_PLATFORM_H_ | 5 #ifndef UI_OZONE_PUBLIC_OZONE_PLATFORM_H_ |
6 #define UI_OZONE_PUBLIC_OZONE_PLATFORM_H_ | 6 #define UI_OZONE_PUBLIC_OZONE_PLATFORM_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
| 10 #include "base/auto_reset.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
12 #include "ui/ozone/ozone_export.h" | 13 #include "ui/ozone/ozone_export.h" |
13 | 14 |
14 namespace display { | 15 namespace display { |
15 class NativeDisplayDelegate; | 16 class NativeDisplayDelegate; |
16 } | 17 } |
17 | 18 |
18 namespace gfx { | 19 namespace gfx { |
19 class Rect; | 20 class Rect; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // internal functionality. Embedders wishing to take advantage of ozone mojo | 120 // internal functionality. Embedders wishing to take advantage of ozone mojo |
120 // implementations must invoke AddInterfaces with a valid | 121 // implementations must invoke AddInterfaces with a valid |
121 // service_manager::InterfaceRegistry* pointer to export all Mojo interfaces | 122 // service_manager::InterfaceRegistry* pointer to export all Mojo interfaces |
122 // defined within Ozone. | 123 // defined within Ozone. |
123 // | 124 // |
124 // A default do-nothing implementation is provided to permit platform | 125 // A default do-nothing implementation is provided to permit platform |
125 // implementations to opt out of implementing any Mojo interfaces. | 126 // implementations to opt out of implementing any Mojo interfaces. |
126 virtual void AddInterfaces(service_manager::InterfaceRegistry* registry); | 127 virtual void AddInterfaces(service_manager::InterfaceRegistry* registry); |
127 | 128 |
128 private: | 129 private: |
| 130 friend class ScopedOzonePlatformForTesting; |
| 131 |
129 virtual void InitializeUI(const InitParams& params) = 0; | 132 virtual void InitializeUI(const InitParams& params) = 0; |
130 virtual void InitializeGPU(const InitParams& params) = 0; | 133 virtual void InitializeGPU(const InitParams& params) = 0; |
131 | 134 |
132 static OzonePlatform* instance_; | 135 static OzonePlatform* instance_; |
133 | 136 |
134 DISALLOW_COPY_AND_ASSIGN(OzonePlatform); | 137 DISALLOW_COPY_AND_ASSIGN(OzonePlatform); |
135 }; | 138 }; |
136 | 139 |
| 140 // Allows the ozone platform instance to be overridden in tests. |
| 141 class OZONE_EXPORT ScopedOzonePlatformForTesting { |
| 142 public: |
| 143 ScopedOzonePlatformForTesting(OzonePlatform* test_instance); |
| 144 ~ScopedOzonePlatformForTesting(); |
| 145 |
| 146 private: |
| 147 base::AutoReset<OzonePlatform*> auto_reset_; |
| 148 |
| 149 DISALLOW_COPY_AND_ASSIGN(ScopedOzonePlatformForTesting); |
| 150 }; |
| 151 |
137 } // namespace ui | 152 } // namespace ui |
138 | 153 |
139 #endif // UI_OZONE_PUBLIC_OZONE_PLATFORM_H_ | 154 #endif // UI_OZONE_PUBLIC_OZONE_PLATFORM_H_ |
OLD | NEW |