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

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

Issue 44053005: Implement --ozone-platform flag to select OzonePlatform implementation at runtime (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove obsolete CreateDefaultOzonePlatform() prototype Created 7 years, 1 month 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ui/base/ozone/ozone_platform.h" 7 #include "ui/base/ozone/ozone_platform.h"
8 #include "ui/base/ozone/ozone_platform_list.h"
9 #include "ui/base/ozone/ozone_switches.h"
8 10
9 namespace ui { 11 namespace ui {
10 12
13 namespace {
14
15 OzonePlatform* CreatePlatform(const std::string& platform_name) {
16 for (int i = 0; i < kOzonePlatformCount; ++i)
rjkroege 2013/10/28 16:02:15 default maps to the first element in the list righ
spang 2013/10/28 16:27:39 Done.
17 if (platform_name == kOzonePlatforms[i].name || platform_name == "default")
18 return kOzonePlatforms[i].constructor();
19
20 LOG(FATAL) << "Invalid ozone platform: " << platform_name;
21 return NULL; // not reached
22 }
23
24 std::string GetRequestedPlatform() {
rjkroege 2013/10/28 16:02:15 maybe add a comment here saying "returns the name
spang 2013/10/28 16:27:39 Done.
25 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kOzonePlatform))
26 return "default";
27 return CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
28 switches::kOzonePlatform);
29 }
30
31 } // namespace
32
11 OzonePlatform::OzonePlatform() {} 33 OzonePlatform::OzonePlatform() {}
12 34
13 OzonePlatform::~OzonePlatform() { 35 OzonePlatform::~OzonePlatform() {
14 gfx::SurfaceFactoryOzone::SetInstance(NULL); 36 gfx::SurfaceFactoryOzone::SetInstance(NULL);
15 ui::EventFactoryOzone::SetInstance(NULL); 37 ui::EventFactoryOzone::SetInstance(NULL);
16 } 38 }
17 39
18 // static 40 // static
19 OzonePlatform* OzonePlatform::Create() { 41 OzonePlatform* OzonePlatform::Create() {
20 OzonePlatform* platform = CreateDefaultOzonePlatform(); 42 OzonePlatform* platform = CreatePlatform(GetRequestedPlatform());
21 43
22 gfx::SurfaceFactoryOzone::SetInstance(platform->GetSurfaceFactoryOzone()); 44 gfx::SurfaceFactoryOzone::SetInstance(platform->GetSurfaceFactoryOzone());
23 ui::EventFactoryOzone::SetInstance(platform->GetEventFactoryOzone()); 45 ui::EventFactoryOzone::SetInstance(platform->GetEventFactoryOzone());
24 46
25 return platform; 47 return platform;
26 } 48 }
27 49
28 } // namespace ui 50 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698