| 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_service.h" | 5 #include "components/ukm/ukm_service.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 120 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 121 FROM_HERE, | 121 FROM_HERE, |
| 122 base::Bind(&UkmService::StartInitTask, self_ptr_factory_.GetWeakPtr()), | 122 base::Bind(&UkmService::StartInitTask, self_ptr_factory_.GetWeakPtr()), |
| 123 base::TimeDelta::FromSeconds(kInitializationDelaySeconds)); | 123 base::TimeDelta::FromSeconds(kInitializationDelaySeconds)); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void UkmService::EnableReporting() { | 126 void UkmService::EnableReporting() { |
| 127 DCHECK(thread_checker_.CalledOnValidThread()); | 127 DCHECK(thread_checker_.CalledOnValidThread()); |
| 128 DVLOG(1) << "UkmService::EnableReporting"; | 128 DVLOG(1) << "UkmService::EnableReporting"; |
| 129 #if defined(OFFICIAL_BUILD) | |
| 130 CHECK(false); // Remove this once UKM checks sync state. | |
| 131 #endif | |
| 132 if (!initialize_started_) | 129 if (!initialize_started_) |
| 133 Initialize(); | 130 Initialize(); |
| 134 scheduler_->Start(); | 131 scheduler_->Start(); |
| 135 } | 132 } |
| 136 | 133 |
| 137 void UkmService::DisableReporting() { | 134 void UkmService::DisableReporting() { |
| 138 DCHECK(thread_checker_.CalledOnValidThread()); | 135 DCHECK(thread_checker_.CalledOnValidThread()); |
| 139 DVLOG(1) << "UkmService::DisableReporting"; | 136 DVLOG(1) << "UkmService::DisableReporting"; |
| 140 scheduler_->Stop(); | 137 scheduler_->Stop(); |
| 141 Flush(); | 138 Flush(); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 persisted_logs_.SerializeLogs(); | 238 persisted_logs_.SerializeLogs(); |
| 242 } | 239 } |
| 243 | 240 |
| 244 // Error 400 indicates a problem with the log, not with the server, so | 241 // Error 400 indicates a problem with the log, not with the server, so |
| 245 // don't consider that a sign that the server is in trouble. | 242 // don't consider that a sign that the server is in trouble. |
| 246 bool server_is_healthy = upload_succeeded || response_code == 400; | 243 bool server_is_healthy = upload_succeeded || response_code == 400; |
| 247 scheduler_->UploadFinished(server_is_healthy, !persisted_logs_.empty()); | 244 scheduler_->UploadFinished(server_is_healthy, !persisted_logs_.empty()); |
| 248 } | 245 } |
| 249 | 246 |
| 250 } // namespace ukm | 247 } // namespace ukm |
| OLD | NEW |