| 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/metrics/chrome_metrics_service_client.h" | 5 #include "chrome/browser/metrics/chrome_metrics_service_client.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 return metrics::SystemProfileProto::CHANNEL_DEV; | 90 return metrics::SystemProfileProto::CHANNEL_DEV; |
| 91 case chrome::VersionInfo::CHANNEL_BETA: | 91 case chrome::VersionInfo::CHANNEL_BETA: |
| 92 return metrics::SystemProfileProto::CHANNEL_BETA; | 92 return metrics::SystemProfileProto::CHANNEL_BETA; |
| 93 case chrome::VersionInfo::CHANNEL_STABLE: | 93 case chrome::VersionInfo::CHANNEL_STABLE: |
| 94 return metrics::SystemProfileProto::CHANNEL_STABLE; | 94 return metrics::SystemProfileProto::CHANNEL_STABLE; |
| 95 } | 95 } |
| 96 NOTREACHED(); | 96 NOTREACHED(); |
| 97 return metrics::SystemProfileProto::CHANNEL_UNKNOWN; | 97 return metrics::SystemProfileProto::CHANNEL_UNKNOWN; |
| 98 } | 98 } |
| 99 | 99 |
| 100 // Handles asynchronous fetching of memory details. | |
| 101 // Will run the provided task after finished. | |
| 102 class MetricsMemoryDetails : public MemoryDetails { | |
| 103 public: | |
| 104 MetricsMemoryDetails( | |
| 105 const base::Closure& callback, | |
| 106 MemoryGrowthTracker* memory_growth_tracker) | |
| 107 : callback_(callback) { | |
| 108 SetMemoryGrowthTracker(memory_growth_tracker); | |
| 109 } | |
| 110 | |
| 111 void OnDetailsAvailable() override { | |
| 112 base::MessageLoop::current()->PostTask(FROM_HERE, callback_); | |
| 113 } | |
| 114 | |
| 115 private: | |
| 116 ~MetricsMemoryDetails() override {} | |
| 117 | |
| 118 base::Closure callback_; | |
| 119 | |
| 120 DISALLOW_COPY_AND_ASSIGN(MetricsMemoryDetails); | |
| 121 }; | |
| 122 | |
| 123 } // namespace | 100 } // namespace |
| 124 | 101 |
| 125 ChromeMetricsServiceClient::ChromeMetricsServiceClient( | 102 ChromeMetricsServiceClient::ChromeMetricsServiceClient( |
| 126 metrics::MetricsStateManager* state_manager) | 103 metrics::MetricsStateManager* state_manager) |
| 127 : metrics_state_manager_(state_manager), | 104 : metrics_state_manager_(state_manager), |
| 128 chromeos_metrics_provider_(NULL), | 105 chromeos_metrics_provider_(NULL), |
| 129 waiting_for_collect_final_metrics_step_(false), | 106 waiting_for_collect_final_metrics_step_(false), |
| 130 num_async_histogram_fetches_in_progress_(0), | 107 num_async_histogram_fetches_in_progress_(0), |
| 131 weak_ptr_factory_(this) { | 108 weak_ptr_factory_(this) { |
| 132 DCHECK(thread_checker_.CalledOnValidThread()); | 109 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 // then call OnHistogramSynchronizationDone to continue processing. | 217 // then call OnHistogramSynchronizationDone to continue processing. |
| 241 DCHECK(!waiting_for_collect_final_metrics_step_); | 218 DCHECK(!waiting_for_collect_final_metrics_step_); |
| 242 waiting_for_collect_final_metrics_step_ = true; | 219 waiting_for_collect_final_metrics_step_ = true; |
| 243 | 220 |
| 244 base::Closure callback = | 221 base::Closure callback = |
| 245 base::Bind(&ChromeMetricsServiceClient::OnMemoryDetailCollectionDone, | 222 base::Bind(&ChromeMetricsServiceClient::OnMemoryDetailCollectionDone, |
| 246 weak_ptr_factory_.GetWeakPtr()); | 223 weak_ptr_factory_.GetWeakPtr()); |
| 247 | 224 |
| 248 scoped_refptr<MetricsMemoryDetails> details( | 225 scoped_refptr<MetricsMemoryDetails> details( |
| 249 new MetricsMemoryDetails(callback, &memory_growth_tracker_)); | 226 new MetricsMemoryDetails(callback, &memory_growth_tracker_)); |
| 250 details->StartFetch(MemoryDetails::UPDATE_USER_METRICS); | 227 details->StartFetch(); |
| 251 | 228 |
| 252 // Collect WebCore cache information to put into a histogram. | 229 // Collect WebCore cache information to put into a histogram. |
| 253 for (content::RenderProcessHost::iterator i( | 230 for (content::RenderProcessHost::iterator i( |
| 254 content::RenderProcessHost::AllHostsIterator()); | 231 content::RenderProcessHost::AllHostsIterator()); |
| 255 !i.IsAtEnd(); i.Advance()) { | 232 !i.IsAtEnd(); i.Advance()) { |
| 256 i.GetCurrentValue()->Send(new ChromeViewMsg_GetCacheResourceStats()); | 233 i.GetCurrentValue()->Send(new ChromeViewMsg_GetCacheResourceStats()); |
| 257 } | 234 } |
| 258 } | 235 } |
| 259 | 236 |
| 260 scoped_ptr<metrics::MetricsLogUploader> | 237 scoped_ptr<metrics::MetricsLogUploader> |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 // Capture the histogram samples. | 536 // Capture the histogram samples. |
| 560 if (dumps_with_crash != 0) | 537 if (dumps_with_crash != 0) |
| 561 UMA_HISTOGRAM_COUNTS("Chrome.BrowserDumpsWithCrash", dumps_with_crash); | 538 UMA_HISTOGRAM_COUNTS("Chrome.BrowserDumpsWithCrash", dumps_with_crash); |
| 562 if (dumps_with_no_crash != 0) | 539 if (dumps_with_no_crash != 0) |
| 563 UMA_HISTOGRAM_COUNTS("Chrome.BrowserDumpsWithNoCrash", dumps_with_no_crash); | 540 UMA_HISTOGRAM_COUNTS("Chrome.BrowserDumpsWithNoCrash", dumps_with_no_crash); |
| 564 int total_dumps = dumps_with_crash + dumps_with_no_crash; | 541 int total_dumps = dumps_with_crash + dumps_with_no_crash; |
| 565 if (total_dumps != 0) | 542 if (total_dumps != 0) |
| 566 UMA_HISTOGRAM_COUNTS("Chrome.BrowserCrashDumpAttempts", total_dumps); | 543 UMA_HISTOGRAM_COUNTS("Chrome.BrowserCrashDumpAttempts", total_dumps); |
| 567 } | 544 } |
| 568 #endif // defined(OS_WIN) | 545 #endif // defined(OS_WIN) |
| OLD | NEW |