blob: 27011aa6175c34070ca10de71e64e9c1d736195b [file] [log] [blame]
olivierrobinc3dfc5b2015-04-07 19:12:001// 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
paulmiller234ec232017-06-05 23:50:135#include "components/metrics/version_utils.h"
olivierrobinc3dfc5b2015-04-07 19:12:006
7#include "base/logging.h"
sdefresne0131ca22015-09-28 12:16:158#include "build/build_config.h"
sdefresne9fb67692015-08-03 18:48:229#include "components/version_info/version_info.h"
olivierrobinc3dfc5b2015-04-07 19:12:0010
11namespace metrics {
12
13std::string GetVersionString() {
sdefresne0131ca22015-09-28 12:16:1514 std::string version = version_info::GetVersionNumber();
olivierrobinc3dfc5b2015-04-07 19:12:0015#if defined(ARCH_CPU_64_BITS)
16 version += "-64";
17#endif // defined(ARCH_CPU_64_BITS)
Alexei Svitkine43027122018-09-05 19:12:4818
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())
olivierrobinc3dfc5b2015-04-07 19:12:0025 version.append("-devel");
26 return version;
27}
28
paulmiller234ec232017-06-05 23:50:1329SystemProfileProto::Channel AsProtobufChannel(version_info::Channel channel) {
olivierrobinc3dfc5b2015-04-07 19:12:0030 switch (channel) {
sdefresne6e883e42015-07-30 08:05:5431 case version_info::Channel::UNKNOWN:
olivierrobinc3dfc5b2015-04-07 19:12:0032 return SystemProfileProto::CHANNEL_UNKNOWN;
sdefresne6e883e42015-07-30 08:05:5433 case version_info::Channel::CANARY:
olivierrobinc3dfc5b2015-04-07 19:12:0034 return SystemProfileProto::CHANNEL_CANARY;
sdefresne6e883e42015-07-30 08:05:5435 case version_info::Channel::DEV:
olivierrobinc3dfc5b2015-04-07 19:12:0036 return SystemProfileProto::CHANNEL_DEV;
sdefresne6e883e42015-07-30 08:05:5437 case version_info::Channel::BETA:
olivierrobinc3dfc5b2015-04-07 19:12:0038 return SystemProfileProto::CHANNEL_BETA;
sdefresne6e883e42015-07-30 08:05:5439 case version_info::Channel::STABLE:
olivierrobinc3dfc5b2015-04-07 19:12:0040 return SystemProfileProto::CHANNEL_STABLE;
41 }
42 NOTREACHED();
43 return SystemProfileProto::CHANNEL_UNKNOWN;
44}
45
46} // namespace metrics