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

Side by Side Diff: ui/ozone/public/ozone_platform.cc

Issue 2629983002: Fix the MessageLoop type in case more than one ozone platform is built (Closed)
Patch Set: addressed kbr's feedback Created 3 years, 10 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/ozone/public/ozone_platform.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 22 matching lines...) Expand all
33 } 33 }
34 34
35 // static 35 // static
36 void OzonePlatform::InitializeForUI() { 36 void OzonePlatform::InitializeForUI() {
37 const InitParams params; 37 const InitParams params;
38 OzonePlatform::InitializeForUI(params); 38 OzonePlatform::InitializeForUI(params);
39 } 39 }
40 40
41 // static 41 // static
42 void OzonePlatform::InitializeForUI(const InitParams& args) { 42 void OzonePlatform::InitializeForUI(const InitParams& args) {
43 CreateInstance(); 43 EnsureInstance();
44 if (g_platform_initialized_ui) 44 if (g_platform_initialized_ui)
45 return; 45 return;
46 g_platform_initialized_ui = true; 46 g_platform_initialized_ui = true;
47 instance_->InitializeUI(args); 47 instance_->InitializeUI(args);
48 // This is deliberately created after initializing so that the platform can 48 // This is deliberately created after initializing so that the platform can
49 // create its own version of DDM. 49 // create its own version of DDM.
50 DeviceDataManager::CreateInstance(); 50 DeviceDataManager::CreateInstance();
51 } 51 }
52 52
53 // static 53 // static
54 void OzonePlatform::InitializeForGPU() { 54 void OzonePlatform::InitializeForGPU() {
55 const InitParams params; 55 const InitParams params;
56 OzonePlatform::InitializeForGPU(params); 56 OzonePlatform::InitializeForGPU(params);
57 } 57 }
58 58
59 // static 59 // static
60 void OzonePlatform::InitializeForGPU(const InitParams& args) { 60 void OzonePlatform::InitializeForGPU(const InitParams& args) {
61 CreateInstance(); 61 EnsureInstance();
62 if (g_platform_initialized_gpu) 62 if (g_platform_initialized_gpu)
63 return; 63 return;
64 g_platform_initialized_gpu = true; 64 g_platform_initialized_gpu = true;
65 instance_->InitializeGPU(args); 65 instance_->InitializeGPU(args);
66 } 66 }
67 67
68 // static 68 // static
69 OzonePlatform* OzonePlatform::GetInstance() { 69 OzonePlatform* OzonePlatform::GetInstance() {
70 DCHECK(instance_) << "OzonePlatform is not initialized"; 70 DCHECK(instance_) << "OzonePlatform is not initialized";
71 return instance_; 71 return instance_;
72 } 72 }
73 73
74 // static 74 // static
75 void OzonePlatform::CreateInstance() { 75 OzonePlatform* OzonePlatform::EnsureInstance() {
76 if (!instance_) { 76 if (!instance_) {
77 TRACE_EVENT1("ozone", 77 TRACE_EVENT1("ozone",
78 "OzonePlatform::Initialize", 78 "OzonePlatform::Initialize",
79 "platform", 79 "platform",
80 GetOzonePlatformName()); 80 GetOzonePlatformName());
81 std::unique_ptr<OzonePlatform> platform = 81 std::unique_ptr<OzonePlatform> platform =
82 PlatformObject<OzonePlatform>::Create(); 82 PlatformObject<OzonePlatform>::Create();
83 83
84 // TODO(spang): Currently need to leak this object. 84 // TODO(spang): Currently need to leak this object.
85 OzonePlatform* pl = platform.release(); 85 OzonePlatform* pl = platform.release();
86 DCHECK_EQ(instance_, pl); 86 DCHECK_EQ(instance_, pl);
87 } 87 }
88 return instance_;
88 } 89 }
89 90
90 // static 91 // static
91 OzonePlatform* OzonePlatform::instance_; 92 OzonePlatform* OzonePlatform::instance_;
92 93
93 // Convenience methods to facilitate transitionning to new API. 94 // Convenience methods to facilitate transitionning to new API.
94 void OzonePlatform::InitializeUI(const InitParams& args) { 95 void OzonePlatform::InitializeUI(const InitParams& args) {
95 InitializeUI(); 96 InitializeUI();
96 } 97 }
98
97 void OzonePlatform::InitializeGPU(const InitParams& args) { 99 void OzonePlatform::InitializeGPU(const InitParams& args) {
98 InitializeGPU(); 100 InitializeGPU();
99 } 101 }
100 102
101 IPC::MessageFilter* OzonePlatform::GetGpuMessageFilter() { 103 IPC::MessageFilter* OzonePlatform::GetGpuMessageFilter() {
102 return nullptr; 104 return nullptr;
103 } 105 }
106
107 base::MessageLoop::Type OzonePlatform::GetMessageLoopTypeForGpu() {
108 return base::MessageLoop::TYPE_DEFAULT;
109 }
110
104 void OzonePlatform::AddInterfaces( 111 void OzonePlatform::AddInterfaces(
105 service_manager::InterfaceRegistry* registry) {} 112 service_manager::InterfaceRegistry* registry) {}
106 113
107 } // namespace ui 114 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/public/ozone_platform.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698