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/processes/processes_api.h" | 5 #include "chrome/browser/extensions/api/processes/processes_api.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 blink::WebCache::ResourceTypeStats cache_stats; | 175 blink::WebCache::ResourceTypeStats cache_stats; |
176 if (model->GetWebCoreCacheStats(index, &cache_stats)) { | 176 if (model->GetWebCoreCacheStats(index, &cache_stats)) { |
177 result->Set(keys::kImageCacheKey, | 177 result->Set(keys::kImageCacheKey, |
178 CreateCacheData(cache_stats.images)); | 178 CreateCacheData(cache_stats.images)); |
179 result->Set(keys::kScriptCacheKey, | 179 result->Set(keys::kScriptCacheKey, |
180 CreateCacheData(cache_stats.scripts)); | 180 CreateCacheData(cache_stats.scripts)); |
181 result->Set(keys::kCssCacheKey, | 181 result->Set(keys::kCssCacheKey, |
182 CreateCacheData(cache_stats.cssStyleSheets)); | 182 CreateCacheData(cache_stats.cssStyleSheets)); |
183 } | 183 } |
184 | 184 |
185 // Network and FPS are reported by the TaskManager per resource (tab), not | 185 // Network is reported by the TaskManager per resource (tab), not per |
186 // per process, therefore we need to iterate through the group of resources | 186 // process, therefore we need to iterate through the group of resources |
187 // and aggregate the data. | 187 // and aggregate the data. |
188 float fps = 0, tmp = 0; | |
189 int64 net = 0; | 188 int64 net = 0; |
190 int length = model->GetGroupRangeForResource(index).second; | 189 int length = model->GetGroupRangeForResource(index).second; |
191 for (int i = 0; i < length; ++i) { | 190 for (int i = 0; i < length; ++i) |
192 net += model->GetNetworkUsage(index + i); | 191 net += model->GetNetworkUsage(index + i); |
193 if (model->GetFPS(index + i, &tmp)) | |
194 fps += tmp; | |
195 } | |
196 result->SetDouble(keys::kFPSKey, static_cast<double>(fps)); | |
197 result->SetDouble(keys::kNetworkKey, static_cast<double>(net)); | 192 result->SetDouble(keys::kNetworkKey, static_cast<double>(net)); |
198 | 193 |
199 return result; | 194 return result; |
200 } | 195 } |
201 | 196 |
202 // Since memory details are expensive to gather, we don't do it by default. | 197 // Since memory details are expensive to gather, we don't do it by default. |
203 // This function is a helper to add memory details data to an existing | 198 // This function is a helper to add memory details data to an existing |
204 // Process object representation. | 199 // Process object representation. |
205 void AddMemoryDetails(base::DictionaryValue* result, | 200 void AddMemoryDetails(base::DictionaryValue* result, |
206 TaskManagerModel* model, | 201 TaskManagerModel* model, |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 | 757 |
763 SetResult(processes); | 758 SetResult(processes); |
764 SendResponse(true); | 759 SendResponse(true); |
765 | 760 |
766 // Balance the AddRef in the RunAsync. | 761 // Balance the AddRef in the RunAsync. |
767 Release(); | 762 Release(); |
768 #endif // defined(ENABLE_TASK_MANAGER) | 763 #endif // defined(ENABLE_TASK_MANAGER) |
769 } | 764 } |
770 | 765 |
771 } // namespace extensions | 766 } // namespace extensions |
OLD | NEW |