xunjieli | abea839 | 2016-10-06 18:43:26 | [diff] [blame] | 1 | // Copyright 2016 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 | |
Caleb Raitto | 95c93c0 | 2019-01-23 17:49:12 | [diff] [blame] | 5 | #include "components/cronet/metrics_util.h" |
xunjieli | abea839 | 2016-10-06 18:43:26 | [diff] [blame] | 6 | |
Hans Wennborg | df87046c | 2020-04-28 11:06:24 | [diff] [blame] | 7 | #include "base/check.h" |
xunjieli | abea839 | 2016-10-06 18:43:26 | [diff] [blame] | 8 | |
| 9 | namespace cronet { |
| 10 | |
| 11 | namespace metrics_util { |
| 12 | |
| 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()) { |
Caleb Raitto | 95c93c0 | 2019-01-23 17:49:12 | [diff] [blame] | 17 | return kNullTime; |
xunjieli | abea839 | 2016-10-06 18:43:26 | [diff] [blame] | 18 | } |
| 19 | DCHECK(!start_time.is_null()); |
| 20 | return (start_time + (ticks - start_ticks)).ToJavaTime(); |
| 21 | } |
| 22 | |
| 23 | } // namespace metrics_util |
| 24 | |
| 25 | } // namespace cronet |