| 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" |
| 11 #include "content/public/browser/notification_service.h" | 11 #include "content/public/browser/notification_service.h" |
| 12 #include "content/public/browser/notification_source.h" | 12 #include "content/public/browser/notification_source.h" |
| 13 #include "content/public/browser/notification_types.h" | 13 #include "content/public/browser/notification_types.h" |
| 14 | 14 |
| 15 namespace extensions { | 15 namespace extensions { |
| 16 | 16 |
| 17 using api::experimental_system_info_cpu::CpuInfo; | 17 using api::system_info_cpu::CpuInfo; |
| 18 using api::experimental_system_info_cpu::CpuUpdateInfo; | 18 using api::system_info_cpu::CpuUpdateInfo; |
| 19 using content::BrowserThread; | 19 using content::BrowserThread; |
| 20 | 20 |
| 21 // Default sampling interval is 1000ms. | 21 // Default sampling interval is 1000ms. |
| 22 const unsigned int kDefaultSamplingIntervalMs = 1000; | 22 const unsigned int kDefaultSamplingIntervalMs = 1000; |
| 23 | 23 |
| 24 CpuInfoProvider::CpuInfoProvider() | 24 CpuInfoProvider::CpuInfoProvider() |
| 25 : is_sampling_started_(false), | 25 : is_sampling_started_(false), |
| 26 sampling_timer_(NULL), | 26 sampling_timer_(NULL), |
| 27 sampling_interval_(kDefaultSamplingIntervalMs) { | 27 sampling_interval_(kDefaultSamplingIntervalMs) { |
| 28 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, | 28 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 134 } |
| 135 | 135 |
| 136 info->average_usage = total_usage / next_cpu_time.size(); | 136 info->average_usage = total_usage / next_cpu_time.size(); |
| 137 if (!callback_.is_null()) | 137 if (!callback_.is_null()) |
| 138 callback_.Run(info.Pass()); | 138 callback_.Run(info.Pass()); |
| 139 // Use next_cpu_time as baseline_cpu_time_ for the next sampling cycle. | 139 // Use next_cpu_time as baseline_cpu_time_ for the next sampling cycle. |
| 140 baseline_cpu_time_.swap(next_cpu_time); | 140 baseline_cpu_time_.swap(next_cpu_time); |
| 141 } | 141 } |
| 142 | 142 |
| 143 } // namespace extensions | 143 } // namespace extensions |
| OLD | NEW |