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 // Contains UKM data for a single navigation entry. | 19 // Contains UKM data for a single navigation entry. |
20 class UkmSource { | 20 class UkmSource { |
21 public: | 21 public: |
22 UkmSource(); | 22 UkmSource(); |
23 ~UkmSource(); | 23 ~UkmSource(); |
24 | 24 |
25 int32_t id() const { return id_; } | 25 int32_t id() const { return id_; } |
26 void set_id(int32_t id) { id_ = id; } | 26 void set_id(int32_t id) { id_ = id; } |
27 | 27 |
| 28 const GURL& initial_url() const { return initial_url_; } |
28 const GURL& url() const { return url_; } | 29 const GURL& url() const { return url_; } |
| 30 |
| 31 // Sets the URL for this source. Should be invoked when a source is |
| 32 // initialized. |
29 void set_url(const GURL& url) { url_ = url; } | 33 void set_url(const GURL& url) { url_ = url; } |
30 | 34 |
| 35 // 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 |
| 37 // original URL provided to set_url, and the url field is updated with the |
| 38 // value provided to this method. |
| 39 void UpdateUrl(const GURL& url); |
| 40 |
31 // Serializes the members of the class into the supplied proto. | 41 // Serializes the members of the class into the supplied proto. |
32 void PopulateProto(Source* proto_source) const; | 42 void PopulateProto(Source* proto_source) const; |
33 | 43 |
34 private: | 44 private: |
35 int32_t id_; | 45 int32_t id_; |
| 46 |
| 47 // The final, canonical URL for this source. |
36 GURL url_; | 48 GURL url_; |
37 | 49 |
| 50 // 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). |
| 52 GURL initial_url_; |
| 53 |
38 DISALLOW_COPY_AND_ASSIGN(UkmSource); | 54 DISALLOW_COPY_AND_ASSIGN(UkmSource); |
39 }; | 55 }; |
40 | 56 |
41 } // namespace ukm | 57 } // namespace ukm |
42 | 58 |
43 #endif // COMPONENTS_UKM_UKM_SOURCE_H_ | 59 #endif // COMPONENTS_UKM_UKM_SOURCE_H_ |
OLD | NEW |