OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/api/system_info_cpu/cpu_info_provider.h" | 5 #include "chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h" |
6 | 6 |
7 #include "base/sys_info.h" | 7 #include "base/sys_info.h" |
8 #include "chrome/common/chrome_notification_types.h" | 8 #include "chrome/common/chrome_notification_types.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "content/public/browser/notification_details.h" | 10 #include "content/public/browser/notification_details.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 CpuInfoProvider::~CpuInfoProvider() { | 32 CpuInfoProvider::~CpuInfoProvider() { |
33 DCHECK(sampling_timer_ == NULL); | 33 DCHECK(sampling_timer_ == NULL); |
34 registrar_.RemoveAll(); | 34 registrar_.RemoveAll(); |
35 } | 35 } |
36 | 36 |
37 bool CpuInfoProvider::QueryInfo(CpuInfo* info) { | 37 bool CpuInfoProvider::QueryInfo(CpuInfo* info) { |
38 if (info == NULL) | 38 if (info == NULL) |
39 return false; | 39 return false; |
40 | 40 |
41 info->num_of_processors = base::SysInfo::NumberOfProcessors(); | 41 info->num_of_processors = base::SysInfo::NumberOfProcessors(); |
42 info->arch_name = base::SysInfo::CPUArchitecture(); | 42 info->arch_name = base::SysInfo::OperatingSystemArchitecture(); |
43 info->model_name = base::SysInfo::CPUModelName(); | 43 info->model_name = base::SysInfo::CPUModelName(); |
44 return true; | 44 return true; |
45 } | 45 } |
46 | 46 |
47 void CpuInfoProvider::StartSampling(const SamplingCallback& callback) { | 47 void CpuInfoProvider::StartSampling(const SamplingCallback& callback) { |
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
49 BrowserThread::PostTask( | 49 BrowserThread::PostTask( |
50 BrowserThread::FILE, | 50 BrowserThread::FILE, |
51 FROM_HERE, | 51 FROM_HERE, |
52 base::Bind(&CpuInfoProvider::StartSamplingOnFileThread, | 52 base::Bind(&CpuInfoProvider::StartSamplingOnFileThread, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 136 } |
137 | 137 |
138 info->average_usage = total_usage / next_cpu_time.size(); | 138 info->average_usage = total_usage / next_cpu_time.size(); |
139 if (!callback_.is_null()) | 139 if (!callback_.is_null()) |
140 callback_.Run(info.Pass()); | 140 callback_.Run(info.Pass()); |
141 // Use next_cpu_time as baseline_cpu_time_ for the next sampling cycle. | 141 // Use next_cpu_time as baseline_cpu_time_ for the next sampling cycle. |
142 baseline_cpu_time_.swap(next_cpu_time); | 142 baseline_cpu_time_.swap(next_cpu_time); |
143 } | 143 } |
144 | 144 |
145 } // namespace extensions | 145 } // namespace extensions |
OLD | NEW |