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

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

Issue 313963007: ozone: Implement PlatformObject<T> for platform-specific objects (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix namespacing Created 6 years, 6 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 | Annotate | Revision Log
« ui/ozone/platform_object.h ('K') | « ui/ozone/platform_selection.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
(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 "base/command_line.h"
6 #include "base/logging.h"
7 #include "ui/ozone/ozone_switches.h"
8 #include "ui/ozone/platform_list.h"
9
10 namespace ui {
11
12 namespace {
13
14 // Returns the name of the platform to use (value of --ozone-platform flag).
15 std::string GetPlatformName() {
16 // The first platform is the default.
17 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kOzonePlatform) &&
18 kPlatformCount > 0)
19 return kPlatformNames[0];
20 return CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
21 switches::kOzonePlatform);
22 }
23
24 int g_selected_platform = -1;
25
26 } // namespace
27
28 int GetOzonePlatformId() {
29 if (g_selected_platform >= 0)
30 return g_selected_platform;
31
32 std::string platform_name = GetPlatformName();
33
34 // Search for a matching platform in the list.
35 for (int platform_id = 0; platform_id < kPlatformCount; ++platform_id) {
36 if (platform_name == kPlatformNames[platform_id]) {
37 g_selected_platform = platform_id;
38 return g_selected_platform;
39 }
40 }
41
42 LOG(FATAL) << "Invalid ozone platform: " << platform_name;
43 return -1; // not reached
44 }
45
46 const char* GetOzonePlatformName() {
47 return kPlatformNames[GetOzonePlatformId()];
48 }
49
50 } // namespace ui
OLDNEW
« ui/ozone/platform_object.h ('K') | « ui/ozone/platform_selection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698