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

Side by Side Diff: chrome_frame/metrics_service.cc

Issue 5845004: Stop upload thread when stopping service. Leaked thread may crash process on... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 5
6 //------------------------------------------------------------------------------ 6 //------------------------------------------------------------------------------
7 // Description of the life cycle of a instance of MetricsService. 7 // Description of the life cycle of a instance of MetricsService.
8 // 8 //
9 // OVERVIEW 9 // OVERVIEW
10 // 10 //
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 115 }
116 return upload_thread; 116 return upload_thread;
117 } 117 }
118 }; 118 };
119 119
120 // ChromeFrame UMA uploads occur on this thread. This thread is started on the 120 // ChromeFrame UMA uploads occur on this thread. This thread is started on the
121 // IE UI thread. This thread needs to be stopped on the same thread it was 121 // IE UI thread. This thread needs to be stopped on the same thread it was
122 // started on. We don't have a good way of achieving this at this point. This 122 // started on. We don't have a good way of achieving this at this point. This
123 // thread object is currently leaked. 123 // thread object is currently leaked.
124 // TODO(ananta) 124 // TODO(ananta)
125 // Fix this. 125 // TODO(vitalybuka@chromium.org) : Fix this by using MetricsService::Stop() in
126 // appropriate location.
126 base::LazyInstance<base::Thread, UploadThreadInstanceTraits> 127 base::LazyInstance<base::Thread, UploadThreadInstanceTraits>
127 g_metrics_upload_thread_(base::LINKER_INITIALIZED); 128 g_metrics_upload_thread_(base::LINKER_INITIALIZED);
128 129
129 Lock g_metrics_service_lock; 130 Lock g_metrics_service_lock;
130 131
131 extern base::LazyInstance<base::StatisticsRecorder> g_statistics_recorder_; 132 extern base::LazyInstance<base::StatisticsRecorder> g_statistics_recorder_;
132 133
133 // This class provides HTTP request context information for metrics upload 134 // This class provides HTTP request context information for metrics upload
134 // requests initiated by ChromeFrame. 135 // requests initiated by ChromeFrame.
135 class ChromeFrameUploadRequestContext : public URLRequestContext { 136 class ChromeFrameUploadRequestContext : public URLRequestContext {
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 if (GetInstance()->state_ == ACTIVE) 403 if (GetInstance()->state_ == ACTIVE)
403 return; 404 return;
404 405
405 GetInstance()->InitializeMetricsState(); 406 GetInstance()->InitializeMetricsState();
406 GetInstance()->SetRecording(true); 407 GetInstance()->SetRecording(true);
407 GetInstance()->SetReporting(true); 408 GetInstance()->SetReporting(true);
408 } 409 }
409 410
410 // static 411 // static
411 void MetricsService::Stop() { 412 void MetricsService::Stop() {
412 AutoLock lock(metrics_service_lock_); 413 {
414 AutoLock lock(metrics_service_lock_);
413 415
414 GetInstance()->SetReporting(false); 416 GetInstance()->SetReporting(false);
415 GetInstance()->SetRecording(false); 417 GetInstance()->SetRecording(false);
418 }
419
420 if (GetInstance()->user_permits_upload_)
421 g_metrics_upload_thread_.Get().Stop();
416 } 422 }
417 423
418 void MetricsService::SetRecording(bool enabled) { 424 void MetricsService::SetRecording(bool enabled) {
419 if (enabled == recording_active_) 425 if (enabled == recording_active_)
420 return; 426 return;
421 427
422 if (enabled) { 428 if (enabled) {
423 if (client_id_.empty()) { 429 if (client_id_.empty()) {
424 client_id_ = GenerateClientID(); 430 client_id_ = GenerateClientID();
425 // Save client id somewhere. 431 // Save client id somewhere.
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 version += "-F"; 610 version += "-F";
605 if (!version_info.IsOfficialBuild()) 611 if (!version_info.IsOfficialBuild())
606 version.append("-devel"); 612 version.append("-devel");
607 return version; 613 return version;
608 } else { 614 } else {
609 NOTREACHED() << "Unable to retrieve version string."; 615 NOTREACHED() << "Unable to retrieve version string.";
610 } 616 }
611 617
612 return std::string(); 618 return std::string();
613 } 619 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698