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 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
8 #include "ui/events/devices/device_data_manager.h" | 8 #include "ui/events/devices/device_data_manager.h" |
9 #include "ui/ozone/platform_object.h" | 9 #include "ui/ozone/platform_object.h" |
10 #include "ui/ozone/platform_selection.h" | 10 #include "ui/ozone/platform_selection.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // static | 47 // static |
48 void OzonePlatform::InitializeForGPU() { | 48 void OzonePlatform::InitializeForGPU() { |
49 CreateInstance(); | 49 CreateInstance(); |
50 if (g_platform_initialized_gpu) | 50 if (g_platform_initialized_gpu) |
51 return; | 51 return; |
52 g_platform_initialized_gpu = true; | 52 g_platform_initialized_gpu = true; |
53 instance_->InitializeGPU(); | 53 instance_->InitializeGPU(); |
54 } | 54 } |
55 | 55 |
56 // static | 56 // static |
| 57 void OzonePlatform::InitializeForTest() { |
| 58 CreateInstance(); |
| 59 DCHECK(!g_platform_initialized_ui); |
| 60 DCHECK(!g_platform_initialized_gpu); |
| 61 g_platform_initialized_ui = true; |
| 62 g_platform_initialized_gpu = true; |
| 63 instance_->InitializeTest(); |
| 64 DeviceDataManager::CreateInstance(); |
| 65 } |
| 66 |
| 67 // static |
57 OzonePlatform* OzonePlatform::GetInstance() { | 68 OzonePlatform* OzonePlatform::GetInstance() { |
58 DCHECK(instance_) << "OzonePlatform is not initialized"; | 69 DCHECK(instance_) << "OzonePlatform is not initialized"; |
59 return instance_; | 70 return instance_; |
60 } | 71 } |
61 | 72 |
62 // static | 73 // static |
63 void OzonePlatform::CreateInstance() { | 74 void OzonePlatform::CreateInstance() { |
64 if (!instance_) { | 75 if (!instance_) { |
65 TRACE_EVENT1("ozone", | 76 TRACE_EVENT1("ozone", |
66 "OzonePlatform::Initialize", | 77 "OzonePlatform::Initialize", |
67 "platform", | 78 "platform", |
68 GetOzonePlatformName()); | 79 GetOzonePlatformName()); |
69 scoped_ptr<OzonePlatform> platform = | 80 scoped_ptr<OzonePlatform> platform = |
70 PlatformObject<OzonePlatform>::Create(); | 81 PlatformObject<OzonePlatform>::Create(); |
71 | 82 |
72 // TODO(spang): Currently need to leak this object. | 83 // TODO(spang): Currently need to leak this object. |
73 OzonePlatform* pl = platform.release(); | 84 OzonePlatform* pl = platform.release(); |
74 DCHECK_EQ(instance_, pl); | 85 DCHECK_EQ(instance_, pl); |
75 } | 86 } |
76 } | 87 } |
77 | 88 |
78 // static | 89 // static |
79 OzonePlatform* OzonePlatform::instance_; | 90 OzonePlatform* OzonePlatform::instance_; |
80 | 91 |
81 } // namespace ui | 92 } // namespace ui |
OLD | NEW |