| 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/caps/generate_state_json.h" | 5 #include "chrome/browser/caps/generate_state_json.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include <string> | 10 #include <string> |
| 8 #include <utility> | 11 #include <utility> |
| 9 | 12 |
| 10 #include "base/bind.h" | 13 #include "base/bind.h" |
| 11 #include "base/cpu.h" | 14 #include "base/cpu.h" |
| 12 #include "base/files/file.h" | 15 #include "base/files/file.h" |
| 13 #include "base/json/json_writer.h" | 16 #include "base/json/json_writer.h" |
| 14 #include "base/location.h" | 17 #include "base/location.h" |
| 15 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
| 18 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 19 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
| 20 #include "base/thread_task_runner_handle.h" | 23 #include "base/thread_task_runner_handle.h" |
| 21 #include "base/threading/thread_restrictions.h" | 24 #include "base/threading/thread_restrictions.h" |
| 22 #include "base/time/time.h" | 25 #include "base/time/time.h" |
| 23 #include "base/values.h" | 26 #include "base/values.h" |
| 27 #include "build/build_config.h" |
| 24 #include "chrome/browser/task_manager/task_manager.h" | 28 #include "chrome/browser/task_manager/task_manager.h" |
| 25 | 29 |
| 26 namespace { | 30 namespace { |
| 27 | 31 |
| 28 std::string Key(base::ProcessId pid, const char* category) { | 32 std::string Key(base::ProcessId pid, const char* category) { |
| 29 return category ? | 33 return category ? |
| 30 base::StringPrintf("process.%d.%s", pid, category) : | 34 base::StringPrintf("process.%d.%s", pid, category) : |
| 31 base::StringPrintf("process.%d", pid); | 35 base::StringPrintf("process.%d", pid); |
| 32 } | 36 } |
| 33 | 37 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 base::CPU cpu; | 112 base::CPU cpu; |
| 109 dict->SetInteger("system.cpu.type", cpu.type()); | 113 dict->SetInteger("system.cpu.type", cpu.type()); |
| 110 dict->SetInteger("system.cpu.family", cpu.family()); | 114 dict->SetInteger("system.cpu.family", cpu.family()); |
| 111 dict->SetInteger("system.cpu.model", cpu.model()); | 115 dict->SetInteger("system.cpu.model", cpu.model()); |
| 112 dict->SetInteger("system.cpu.stepping", cpu.stepping()); | 116 dict->SetInteger("system.cpu.stepping", cpu.stepping()); |
| 113 dict->SetString("system.cpu.brand", cpu.cpu_brand()); | 117 dict->SetString("system.cpu.brand", cpu.cpu_brand()); |
| 114 dict->SetInteger("system.cpu.logicalprocessors", | 118 dict->SetInteger("system.cpu.logicalprocessors", |
| 115 base::SysInfo::NumberOfProcessors()); | 119 base::SysInfo::NumberOfProcessors()); |
| 116 dict->SetInteger("system.cpu.logicalprocessors", | 120 dict->SetInteger("system.cpu.logicalprocessors", |
| 117 base::SysInfo::NumberOfProcessors()); | 121 base::SysInfo::NumberOfProcessors()); |
| 118 int64 memory = base::SysInfo::AmountOfPhysicalMemory(); | 122 int64_t memory = base::SysInfo::AmountOfPhysicalMemory(); |
| 119 dict->SetInteger("system.memory.physical", InMBFromB(memory)); | 123 dict->SetInteger("system.memory.physical", InMBFromB(memory)); |
| 120 memory = base::SysInfo::AmountOfAvailablePhysicalMemory(); | 124 memory = base::SysInfo::AmountOfAvailablePhysicalMemory(); |
| 121 dict->SetInteger("system.memory.available", InMBFromB(memory)); | 125 dict->SetInteger("system.memory.available", InMBFromB(memory)); |
| 122 dict->SetInteger("system.uptime", base::SysInfo::Uptime().InSeconds()); | 126 dict->SetInteger("system.uptime", base::SysInfo::Uptime().InSeconds()); |
| 123 dict->SetString("os.name", base::SysInfo::OperatingSystemName()); | 127 dict->SetString("os.name", base::SysInfo::OperatingSystemName()); |
| 124 #if !defined(OS_LINUX) | 128 #if !defined(OS_LINUX) |
| 125 int32 major, minor, bugfix; | 129 int32_t major, minor, bugfix; |
| 126 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix); | 130 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix); |
| 127 dict->SetInteger("os.version.major", major); | 131 dict->SetInteger("os.version.major", major); |
| 128 dict->SetInteger("os.version.minor", minor); | 132 dict->SetInteger("os.version.minor", minor); |
| 129 dict->SetInteger("os.version.bugfix", bugfix); | 133 dict->SetInteger("os.version.bugfix", bugfix); |
| 130 dict->SetString("os.arch", base::SysInfo::OperatingSystemArchitecture()); | 134 dict->SetString("os.arch", base::SysInfo::OperatingSystemArchitecture()); |
| 131 #endif | 135 #endif |
| 132 } | 136 } |
| 133 | 137 |
| 134 void GatherChromeValues(base::DictionaryValue* dict) { | 138 void GatherChromeValues(base::DictionaryValue* dict) { |
| 135 for (int index = 0; index != model_->ResourceCount(); ++index) { | 139 for (int index = 0; index != model_->ResourceCount(); ++index) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } // namespace | 200 } // namespace |
| 197 | 201 |
| 198 namespace caps { | 202 namespace caps { |
| 199 | 203 |
| 200 void GenerateStateJSON( | 204 void GenerateStateJSON( |
| 201 scoped_refptr<TaskManagerModel> model, base::File file) { | 205 scoped_refptr<TaskManagerModel> model, base::File file) { |
| 202 new TaskManagerDataDumper(model, file.Pass()); | 206 new TaskManagerDataDumper(model, file.Pass()); |
| 203 } | 207 } |
| 204 | 208 |
| 205 } | 209 } |
| OLD | NEW |