blob: 37452330d9e5d5299e38c79f89754dd2773f868c [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
sdefresne55c95762015-09-22 18:30:355#include "components/metrics/net/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)
sdefresne0131ca22015-09-28 12:16:1518 if (!version_info::IsOfficialBuild())
olivierrobinc3dfc5b2015-04-07 19:12:0019 version.append("-devel");
20 return version;
21}
22
23SystemProfileProto::Channel AsProtobufChannel(
sdefresne6e883e42015-07-30 08:05:5424 version_info::Channel channel) {
olivierrobinc3dfc5b2015-04-07 19:12:0025 switch (channel) {
sdefresne6e883e42015-07-30 08:05:5426 case version_info::Channel::UNKNOWN:
olivierrobinc3dfc5b2015-04-07 19:12:0027 return SystemProfileProto::CHANNEL_UNKNOWN;
sdefresne6e883e42015-07-30 08:05:5428 case version_info::Channel::CANARY:
olivierrobinc3dfc5b2015-04-07 19:12:0029 return SystemProfileProto::CHANNEL_CANARY;
sdefresne6e883e42015-07-30 08:05:5430 case version_info::Channel::DEV:
olivierrobinc3dfc5b2015-04-07 19:12:0031 return SystemProfileProto::CHANNEL_DEV;
sdefresne6e883e42015-07-30 08:05:5432 case version_info::Channel::BETA:
olivierrobinc3dfc5b2015-04-07 19:12:0033 return SystemProfileProto::CHANNEL_BETA;
sdefresne6e883e42015-07-30 08:05:5434 case version_info::Channel::STABLE:
olivierrobinc3dfc5b2015-04-07 19:12:0035 return SystemProfileProto::CHANNEL_STABLE;
36 }
37 NOTREACHED();
38 return SystemProfileProto::CHANNEL_UNKNOWN;
39}
40
41} // namespace metrics