| 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 #include <map> | 9 #include <map> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 14 | 14 |
| 15 namespace ukm { | 15 namespace ukm { |
| 16 | 16 |
| 17 class Source; | 17 class Source; |
| 18 | 18 |
| 19 typedef int64_t SourceId; |
| 20 |
| 19 // Contains UKM data for a single navigation entry. | 21 // Contains UKM data for a single navigation entry. |
| 20 class UkmSource { | 22 class UkmSource { |
| 21 public: | 23 public: |
| 22 UkmSource(); | 24 UkmSource(); |
| 23 ~UkmSource(); | 25 ~UkmSource(); |
| 24 | 26 |
| 25 int32_t id() const { return id_; } | 27 ukm::SourceId id() const { return id_; } |
| 26 void set_id(int32_t id) { id_ = id; } | 28 void set_id(ukm::SourceId id) { id_ = id; } |
| 27 | 29 |
| 28 const GURL& initial_url() const { return initial_url_; } | 30 const GURL& initial_url() const { return initial_url_; } |
| 29 const GURL& url() const { return url_; } | 31 const GURL& url() const { return url_; } |
| 30 | 32 |
| 31 // Sets the URL for this source. Should be invoked when a source is | 33 // Sets the URL for this source. Should be invoked when a source is |
| 32 // initialized. | 34 // initialized. |
| 33 void set_url(const GURL& url) { url_ = url; } | 35 void set_url(const GURL& url) { url_ = url; } |
| 34 | 36 |
| 35 // Updates the URL for this source. Must be called after set_url. If a new URL | 37 // Updates the URL for this source. Must be called after set_url. If a new URL |
| 36 // is passed to UpdateUrl, the initial_url field is populated with the | 38 // is passed to UpdateUrl, the initial_url field is populated with the |
| 37 // original URL provided to set_url, and the url field is updated with the | 39 // original URL provided to set_url, and the url field is updated with the |
| 38 // value provided to this method. | 40 // value provided to this method. |
| 39 void UpdateUrl(const GURL& url); | 41 void UpdateUrl(const GURL& url); |
| 40 | 42 |
| 41 // Serializes the members of the class into the supplied proto. | 43 // Serializes the members of the class into the supplied proto. |
| 42 void PopulateProto(Source* proto_source) const; | 44 void PopulateProto(Source* proto_source) const; |
| 43 | 45 |
| 44 private: | 46 private: |
| 45 int32_t id_; | 47 ukm::SourceId id_; |
| 46 | 48 |
| 47 // The final, canonical URL for this source. | 49 // The final, canonical URL for this source. |
| 48 GURL url_; | 50 GURL url_; |
| 49 | 51 |
| 50 // The initial URL for this source. Only set if different from |url_| (i.e. if | 52 // The initial URL for this source. Only set if different from |url_| (i.e. if |
| 51 // the URL changed over the lifetime of this source). | 53 // the URL changed over the lifetime of this source). |
| 52 GURL initial_url_; | 54 GURL initial_url_; |
| 53 | 55 |
| 54 DISALLOW_COPY_AND_ASSIGN(UkmSource); | 56 DISALLOW_COPY_AND_ASSIGN(UkmSource); |
| 55 }; | 57 }; |
| 56 | 58 |
| 57 } // namespace ukm | 59 } // namespace ukm |
| 58 | 60 |
| 59 #endif // COMPONENTS_UKM_UKM_SOURCE_H_ | 61 #endif // COMPONENTS_UKM_UKM_SOURCE_H_ |
| OLD | NEW |