xref: /aosp_15_r20/external/cronet/components/cronet/metrics_util.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2016 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 "components/cronet/metrics_util.h"
6 
7 #include "base/check.h"
8 
9 namespace cronet {
10 
11 namespace metrics_util {
12 
ConvertTime(const base::TimeTicks & ticks,const base::TimeTicks & start_ticks,const base::Time & start_time)13 int64_t ConvertTime(const base::TimeTicks& ticks,
14                     const base::TimeTicks& start_ticks,
15                     const base::Time& start_time) {
16   if (ticks.is_null() || start_ticks.is_null()) {
17     return kNullTime;
18   }
19   DCHECK(!start_time.is_null());
20   return (start_time + (ticks - start_ticks)).InMillisecondsSinceUnixEpoch();
21 }
22 
23 }  // namespace metrics_util
24 
25 }  // namespace cronet
26