xref: /aosp_15_r20/external/cronet/base/version_info/version_info.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2015 The Chromium Authors
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/version_info/version_info.h"
6 
7 #include <string>
8 
9 #include "base/no_destructor.h"
10 #include "base/strings/strcat.h"
11 #include "base/strings/string_number_conversions.h"
12 #include "base/version.h"
13 
14 namespace version_info {
15 
GetMajorVersionNumberAsInt()16 int GetMajorVersionNumberAsInt() {
17   DCHECK(GetVersion().IsValid());
18   return GetVersion().components()[0];
19 }
20 
GetMajorVersionNumber()21 std::string GetMajorVersionNumber() {
22   return base::NumberToString(GetMajorVersionNumberAsInt());
23 }
24 
GetVersion()25 const base::Version& GetVersion() {
26   static const base::NoDestructor<base::Version> version(GetVersionNumber());
27   return *version;
28 }
29 
30 }  // namespace version_info
31