| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_UKM_UKM_SOURCE_H_ | 5 #ifndef COMPONENTS_UKM_UKM_SOURCE_H_ |
| 6 #define COMPONENTS_UKM_UKM_SOURCE_H_ | 6 #define COMPONENTS_UKM_UKM_SOURCE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/optional.h" |
| 11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 12 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 13 | 14 |
| 14 namespace ukm { | 15 namespace ukm { |
| 15 | 16 |
| 16 class Source; | 17 class Source; |
| 17 | 18 |
| 18 // Contains UKM data for a single navigation entry. | 19 // Contains UKM data for a single navigation entry. |
| 19 class UkmSource { | 20 class UkmSource { |
| 20 public: | 21 public: |
| 21 UkmSource(); | 22 UkmSource(); |
| 22 ~UkmSource(); | 23 ~UkmSource(); |
| 23 | 24 |
| 24 const GURL& committed_url() const { return committed_url_; } | 25 const GURL& url() const { return url_; } |
| 25 void set_committed_url(const GURL& committed_url) { | 26 void set_url(const GURL& url) { url_ = url; } |
| 26 committed_url_ = committed_url; | 27 |
| 28 const base::Optional<base::TimeDelta>& parse_start() const { |
| 29 return parse_start_; |
| 30 } |
| 31 void set_parse_start(base::TimeDelta parse_start) { |
| 32 parse_start_ = parse_start; |
| 27 } | 33 } |
| 28 | 34 |
| 29 base::TimeDelta first_contentful_paint() const { | 35 const base::Optional<base::TimeDelta>& first_contentful_paint() const { |
| 30 return first_contentful_paint_; | 36 return first_contentful_paint_; |
| 31 } | 37 } |
| 32 void set_first_contentful_paint(base::TimeDelta first_contentful_paint) { | 38 void set_first_contentful_paint(base::TimeDelta first_contentful_paint) { |
| 33 first_contentful_paint_ = first_contentful_paint; | 39 first_contentful_paint_ = first_contentful_paint; |
| 34 } | 40 } |
| 35 | 41 |
| 42 const base::Optional<base::TimeDelta>& first_meaningful_paint() const { |
| 43 return first_meaningful_paint_; |
| 44 } |
| 45 void set_first_meaningful_paint(base::TimeDelta first_meaningful_paint) { |
| 46 first_meaningful_paint_ = first_meaningful_paint; |
| 47 } |
| 48 |
| 49 const base::Optional<base::TimeDelta>& total_time() const { |
| 50 return total_time_; |
| 51 } |
| 52 void set_total_time(base::TimeDelta total_time) { total_time_ = total_time; } |
| 53 |
| 36 // Serializes the members of the class into the supplied proto. | 54 // Serializes the members of the class into the supplied proto. |
| 37 void PopulateProto(Source* proto_source); | 55 void PopulateProto(Source* proto_source); |
| 38 | 56 |
| 39 private: | 57 private: |
| 40 GURL committed_url_; | 58 GURL url_; |
| 41 base::TimeDelta first_contentful_paint_; | 59 base::Optional<base::TimeDelta> parse_start_; |
| 60 base::Optional<base::TimeDelta> first_contentful_paint_; |
| 61 base::Optional<base::TimeDelta> first_meaningful_paint_; |
| 62 base::Optional<base::TimeDelta> total_time_; |
| 42 | 63 |
| 43 DISALLOW_COPY_AND_ASSIGN(UkmSource); | 64 DISALLOW_COPY_AND_ASSIGN(UkmSource); |
| 44 }; | 65 }; |
| 45 | 66 |
| 46 } // namespace ukm | 67 } // namespace ukm |
| 47 | 68 |
| 48 #endif // COMPONENTS_UKM_UKM_SOURCE_H_ | 69 #endif // COMPONENTS_UKM_UKM_SOURCE_H_ |
| OLD | NEW |