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

Side by Side Diff: ui/ozone/platform_selection.cc

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 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/platform_selection.h ('k') | ui/ozone/public/README » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/ozone/platform_selection.h"
6
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "ui/ozone/platform_list.h"
10 #include "ui/ozone/public/ozone_switches.h"
11
12 namespace ui {
13
14 namespace {
15
16 // Returns the name of the platform to use (value of --ozone-platform flag).
17 std::string GetPlatformName() {
18 // The first platform is the default.
19 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kOzonePlatform) &&
20 kPlatformCount > 0)
21 return kPlatformNames[0];
22 return CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
23 switches::kOzonePlatform);
24 }
25
26 int g_selected_platform = -1;
27
28 } // namespace
29
30 int GetOzonePlatformId() {
31 if (g_selected_platform >= 0)
32 return g_selected_platform;
33
34 std::string platform_name = GetPlatformName();
35
36 // Search for a matching platform in the list.
37 for (int platform_id = 0; platform_id < kPlatformCount; ++platform_id) {
38 if (platform_name == kPlatformNames[platform_id]) {
39 g_selected_platform = platform_id;
40 return g_selected_platform;
41 }
42 }
43
44 LOG(FATAL) << "Invalid ozone platform: " << platform_name;
45 return -1; // not reached
46 }
47
48 const char* GetOzonePlatformName() {
49 return kPlatformNames[GetOzonePlatformId()];
50 }
51
52 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform_selection.h ('k') | ui/ozone/public/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698