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 #include "components/ukm/ukm_source.h" | 5 #include "components/ukm/ukm_source.h" |
6 | 6 |
7 #include "base/hash.h" | 7 #include "base/hash.h" |
8 #include "components/metrics/proto/ukm/source.pb.h" | 8 #include "components/metrics/proto/ukm/source.pb.h" |
9 | 9 |
10 namespace ukm { | 10 namespace ukm { |
11 | 11 |
12 UkmSource::UkmSource() = default; | 12 UkmSource::UkmSource() = default; |
13 | 13 |
14 UkmSource::~UkmSource() = default; | 14 UkmSource::~UkmSource() = default; |
15 | 15 |
| 16 void UkmSource::UpdateUrl(const GURL& url) { |
| 17 DCHECK(!url_.is_empty()); |
| 18 if (url_ == url) |
| 19 return; |
| 20 if (initial_url_.is_empty()) |
| 21 initial_url_ = url_; |
| 22 url_ = url; |
| 23 } |
| 24 |
16 void UkmSource::PopulateProto(Source* proto_source) const { | 25 void UkmSource::PopulateProto(Source* proto_source) const { |
17 DCHECK(!proto_source->has_id()); | 26 DCHECK(!proto_source->has_id()); |
18 DCHECK(!proto_source->has_url()); | 27 DCHECK(!proto_source->has_url()); |
| 28 DCHECK(!proto_source->has_initial_url()); |
19 | 29 |
20 proto_source->set_id(id_); | 30 proto_source->set_id(id_); |
21 proto_source->set_url(url_.spec()); | 31 proto_source->set_url(url_.spec()); |
| 32 if (!initial_url_.is_empty()) |
| 33 proto_source->set_initial_url(initial_url_.spec()); |
22 } | 34 } |
23 | 35 |
24 } // namespace ukm | 36 } // namespace ukm |
OLD | NEW |