OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/local_discovery/service_discovery_client_utility.h" | 5 #include "chrome/browser/local_discovery/service_discovery_client_utility.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "chrome/browser/local_discovery/service_discovery_host_client.h" | 8 #include "chrome/browser/local_discovery/service_discovery_host_client.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 | 10 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 FROM_HERE, | 89 FROM_HERE, |
90 base::Bind(&ServiceDiscoveryClientUtility::ReportSuccess, | 90 base::Bind(&ServiceDiscoveryClientUtility::ReportSuccess, |
91 weak_ptr_factory_.GetWeakPtr()), | 91 weak_ptr_factory_.GetWeakPtr()), |
92 base::TimeDelta::FromSeconds(kReportSuccessAfterSeconds)); | 92 base::TimeDelta::FromSeconds(kReportSuccessAfterSeconds)); |
93 } else { | 93 } else { |
94 restart_attempts_ = -1; | 94 restart_attempts_ = -1; |
95 ReportSuccess(); | 95 ReportSuccess(); |
96 } | 96 } |
97 // Run when host_client_ is created. Callbacks created by InvalidateWatchers | 97 // Run when host_client_ is created. Callbacks created by InvalidateWatchers |
98 // may create new watchers. | 98 // may create new watchers. |
99 if (old_client) | 99 if (old_client.get()) |
100 old_client->InvalidateWatchers(); | 100 old_client->InvalidateWatchers(); |
101 } | 101 } |
102 | 102 |
103 void ServiceDiscoveryClientUtility::ReportSuccess() { | 103 void ServiceDiscoveryClientUtility::ReportSuccess() { |
104 UMA_HISTOGRAM_COUNTS_100("LocalDiscovery.ClientRestartAttempts", | 104 UMA_HISTOGRAM_COUNTS_100("LocalDiscovery.ClientRestartAttempts", |
105 kMaxRestartAttempts - restart_attempts_); | 105 kMaxRestartAttempts - restart_attempts_); |
106 } | 106 } |
107 | 107 |
108 } // namespace local_discovery | 108 } // namespace local_discovery |
OLD | NEW |