OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/metrics_memory_details.h" | 5 #include "chrome/browser/metrics/metrics_memory_details.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/location.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/single_thread_task_runner.h" |
11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/thread_task_runner_handle.h" |
12 #include "components/nacl/common/nacl_process_type.h" | 14 #include "components/nacl/common/nacl_process_type.h" |
13 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
14 #include "content/public/common/content_constants.h" | 16 #include "content/public/common/content_constants.h" |
15 #include "content/public/common/process_type.h" | 17 #include "content/public/common/process_type.h" |
16 | 18 |
17 MemoryGrowthTracker::MemoryGrowthTracker() { | 19 MemoryGrowthTracker::MemoryGrowthTracker() { |
18 } | 20 } |
19 | 21 |
20 MemoryGrowthTracker::~MemoryGrowthTracker() { | 22 MemoryGrowthTracker::~MemoryGrowthTracker() { |
21 } | 23 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 MemoryGrowthTracker* memory_growth_tracker) | 57 MemoryGrowthTracker* memory_growth_tracker) |
56 : callback_(callback), memory_growth_tracker_(memory_growth_tracker) { | 58 : callback_(callback), memory_growth_tracker_(memory_growth_tracker) { |
57 memory_growth_tracker_ = memory_growth_tracker; | 59 memory_growth_tracker_ = memory_growth_tracker; |
58 } | 60 } |
59 | 61 |
60 MetricsMemoryDetails::~MetricsMemoryDetails() { | 62 MetricsMemoryDetails::~MetricsMemoryDetails() { |
61 } | 63 } |
62 | 64 |
63 void MetricsMemoryDetails::OnDetailsAvailable() { | 65 void MetricsMemoryDetails::OnDetailsAvailable() { |
64 UpdateHistograms(); | 66 UpdateHistograms(); |
65 base::MessageLoop::current()->PostTask(FROM_HERE, callback_); | 67 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback_); |
66 } | 68 } |
67 | 69 |
68 void MetricsMemoryDetails::UpdateHistograms() { | 70 void MetricsMemoryDetails::UpdateHistograms() { |
69 // Reports a set of memory metrics to UMA. | 71 // Reports a set of memory metrics to UMA. |
70 // Memory is measured in KB. | 72 // Memory is measured in KB. |
71 | 73 |
72 const ProcessData& browser = *ChromeBrowser(); | 74 const ProcessData& browser = *ChromeBrowser(); |
73 size_t aggregate_memory = 0; | 75 size_t aggregate_memory = 0; |
74 int chrome_count = 0; | 76 int chrome_count = 0; |
75 int extension_count = 0; | 77 int extension_count = 0; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 UMA_HISTOGRAM_CUSTOM_COUNTS("Memory.Swap.NumWrites", swap_info().num_writes, | 289 UMA_HISTOGRAM_CUSTOM_COUNTS("Memory.Swap.NumWrites", swap_info().num_writes, |
288 1, 100000000, 100); | 290 1, 100000000, 100); |
289 | 291 |
290 if (swap_info().orig_data_size > 0 && swap_info().compr_data_size > 0) { | 292 if (swap_info().orig_data_size > 0 && swap_info().compr_data_size > 0) { |
291 UMA_HISTOGRAM_CUSTOM_COUNTS( | 293 UMA_HISTOGRAM_CUSTOM_COUNTS( |
292 "Memory.Swap.CompressionRatio", | 294 "Memory.Swap.CompressionRatio", |
293 swap_info().orig_data_size / swap_info().compr_data_size, 1, 20, 20); | 295 swap_info().orig_data_size / swap_info().compr_data_size, 1, 20, 20); |
294 } | 296 } |
295 } | 297 } |
296 #endif // defined(OS_CHROMEOS) | 298 #endif // defined(OS_CHROMEOS) |
OLD | NEW |