olivierrobin | c3dfc5b | 2015-04-07 19:12:00 | [diff] [blame] | 1 | // Copyright 2015 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 | |
paulmiller | 234ec23 | 2017-06-05 23:50:13 | [diff] [blame] | 5 | #include "components/metrics/version_utils.h" |
olivierrobin | c3dfc5b | 2015-04-07 19:12:00 | [diff] [blame] | 6 | |
| 7 | #include "base/logging.h" |
sdefresne | 0131ca2 | 2015-09-28 12:16:15 | [diff] [blame] | 8 | #include "build/build_config.h" |
sdefresne | 9fb6769 | 2015-08-03 18:48:22 | [diff] [blame] | 9 | #include "components/version_info/version_info.h" |
olivierrobin | c3dfc5b | 2015-04-07 19:12:00 | [diff] [blame] | 10 | |
| 11 | namespace metrics { |
| 12 | |
| 13 | std::string GetVersionString() { |
sdefresne | 0131ca2 | 2015-09-28 12:16:15 | [diff] [blame] | 14 | std::string version = version_info::GetVersionNumber(); |
olivierrobin | c3dfc5b | 2015-04-07 19:12:00 | [diff] [blame] | 15 | #if defined(ARCH_CPU_64_BITS) |
| 16 | version += "-64"; |
| 17 | #endif // defined(ARCH_CPU_64_BITS) |
Alexei Svitkine | 4302712 | 2018-09-05 19:12:48 | [diff] [blame] | 18 | |
| 19 | #if defined(GOOGLE_CHROME_BUILD) |
| 20 | bool is_chrome_branded = true; |
| 21 | #else |
| 22 | bool is_chrome_branded = false; |
| 23 | #endif |
| 24 | if (!is_chrome_branded || !version_info::IsOfficialBuild()) |
olivierrobin | c3dfc5b | 2015-04-07 19:12:00 | [diff] [blame] | 25 | version.append("-devel"); |
| 26 | return version; |
| 27 | } |
| 28 | |
paulmiller | 234ec23 | 2017-06-05 23:50:13 | [diff] [blame] | 29 | SystemProfileProto::Channel AsProtobufChannel(version_info::Channel channel) { |
olivierrobin | c3dfc5b | 2015-04-07 19:12:00 | [diff] [blame] | 30 | switch (channel) { |
sdefresne | 6e883e4 | 2015-07-30 08:05:54 | [diff] [blame] | 31 | case version_info::Channel::UNKNOWN: |
olivierrobin | c3dfc5b | 2015-04-07 19:12:00 | [diff] [blame] | 32 | return SystemProfileProto::CHANNEL_UNKNOWN; |
sdefresne | 6e883e4 | 2015-07-30 08:05:54 | [diff] [blame] | 33 | case version_info::Channel::CANARY: |
olivierrobin | c3dfc5b | 2015-04-07 19:12:00 | [diff] [blame] | 34 | return SystemProfileProto::CHANNEL_CANARY; |
sdefresne | 6e883e4 | 2015-07-30 08:05:54 | [diff] [blame] | 35 | case version_info::Channel::DEV: |
olivierrobin | c3dfc5b | 2015-04-07 19:12:00 | [diff] [blame] | 36 | return SystemProfileProto::CHANNEL_DEV; |
sdefresne | 6e883e4 | 2015-07-30 08:05:54 | [diff] [blame] | 37 | case version_info::Channel::BETA: |
olivierrobin | c3dfc5b | 2015-04-07 19:12:00 | [diff] [blame] | 38 | return SystemProfileProto::CHANNEL_BETA; |
sdefresne | 6e883e4 | 2015-07-30 08:05:54 | [diff] [blame] | 39 | case version_info::Channel::STABLE: |
olivierrobin | c3dfc5b | 2015-04-07 19:12:00 | [diff] [blame] | 40 | return SystemProfileProto::CHANNEL_STABLE; |
| 41 | } |
| 42 | NOTREACHED(); |
| 43 | return SystemProfileProto::CHANNEL_UNKNOWN; |
| 44 | } |
| 45 | |
| 46 | } // namespace metrics |