Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: components/metrics/reporting_service.cc

Issue 2752073002: Avoid double initializing reporting_service_ (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/metrics/metrics_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // ReportingService handles uploading serialized logs to a server. 5 // ReportingService handles uploading serialized logs to a server.
6 6
7 #include "components/metrics/reporting_service.h" 7 #include "components/metrics/reporting_service.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 25 matching lines...) Expand all
36 DCHECK(client_); 36 DCHECK(client_);
37 DCHECK(local_state); 37 DCHECK(local_state);
38 } 38 }
39 39
40 ReportingService::~ReportingService() { 40 ReportingService::~ReportingService() {
41 DisableReporting(); 41 DisableReporting();
42 } 42 }
43 43
44 void ReportingService::Initialize() { 44 void ReportingService::Initialize() {
45 DCHECK(thread_checker_.CalledOnValidThread()); 45 DCHECK(thread_checker_.CalledOnValidThread());
46 DCHECK(!upload_scheduler_);
46 log_store()->LoadPersistedUnsentLogs(); 47 log_store()->LoadPersistedUnsentLogs();
47 base::Closure send_next_log_callback = base::Bind( 48 base::Closure send_next_log_callback = base::Bind(
48 &ReportingService::SendNextLog, self_ptr_factory_.GetWeakPtr()); 49 &ReportingService::SendNextLog, self_ptr_factory_.GetWeakPtr());
49 upload_scheduler_.reset(new MetricsUploadScheduler(send_next_log_callback)); 50 upload_scheduler_.reset(new MetricsUploadScheduler(send_next_log_callback));
50 } 51 }
51 52
52 void ReportingService::Start() { 53 void ReportingService::Start() {
53 DCHECK(thread_checker_.CalledOnValidThread()); 54 DCHECK(thread_checker_.CalledOnValidThread());
54 if (reporting_active_) 55 if (reporting_active_)
55 upload_scheduler_->Start(); 56 upload_scheduler_->Start();
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // don't consider that a sign that the server is in trouble. 189 // don't consider that a sign that the server is in trouble.
189 bool server_is_healthy = upload_succeeded || response_code == 400; 190 bool server_is_healthy = upload_succeeded || response_code == 400;
190 if (!log_store()->has_unsent_logs()) { 191 if (!log_store()->has_unsent_logs()) {
191 DVLOG(1) << "Stopping upload_scheduler_."; 192 DVLOG(1) << "Stopping upload_scheduler_.";
192 upload_scheduler_->Stop(); 193 upload_scheduler_->Stop();
193 } 194 }
194 upload_scheduler_->UploadFinished(server_is_healthy); 195 upload_scheduler_->UploadFinished(server_is_healthy);
195 } 196 }
196 197
197 } // namespace metrics 198 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/metrics_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698