| 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/task_profiler/task_profiler_data_serializer.h" | 5 #include "chrome/browser/task_profiler/task_profiler_data_serializer.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 87 |
| 88 } | 88 } |
| 89 | 89 |
| 90 } // anonymous namespace | 90 } // anonymous namespace |
| 91 | 91 |
| 92 namespace task_profiler { | 92 namespace task_profiler { |
| 93 | 93 |
| 94 // static | 94 // static |
| 95 void TaskProfilerDataSerializer::ToValue( | 95 void TaskProfilerDataSerializer::ToValue( |
| 96 const ProcessDataSnapshot& process_data, | 96 const ProcessDataSnapshot& process_data, |
| 97 content::ProcessType process_type, | 97 int process_type, |
| 98 base::DictionaryValue* dictionary) { | 98 base::DictionaryValue* dictionary) { |
| 99 scoped_ptr<base::ListValue> tasks_list(new base::ListValue); | 99 scoped_ptr<base::ListValue> tasks_list(new base::ListValue); |
| 100 for (std::vector<TaskSnapshot>::const_iterator it = | 100 for (std::vector<TaskSnapshot>::const_iterator it = |
| 101 process_data.tasks.begin(); | 101 process_data.tasks.begin(); |
| 102 it != process_data.tasks.end(); ++it) { | 102 it != process_data.tasks.end(); ++it) { |
| 103 scoped_ptr<DictionaryValue> snapshot(new DictionaryValue); | 103 scoped_ptr<DictionaryValue> snapshot(new DictionaryValue); |
| 104 TaskSnapshotToValue(*it, snapshot.get()); | 104 TaskSnapshotToValue(*it, snapshot.get()); |
| 105 tasks_list->Append(snapshot.release()); | 105 tasks_list->Append(snapshot.release()); |
| 106 } | 106 } |
| 107 dictionary->Set("list", tasks_list.release()); | 107 dictionary->Set("list", tasks_list.release()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 snapshot_list->Append(shutdown_snapshot); | 156 snapshot_list->Append(shutdown_snapshot); |
| 157 root->Set("snapshots", snapshot_list); | 157 root->Set("snapshots", snapshot_list); |
| 158 | 158 |
| 159 serializer.Serialize(*root); | 159 serializer.Serialize(*root); |
| 160 int data_size = static_cast<int>(output.size()); | 160 int data_size = static_cast<int>(output.size()); |
| 161 | 161 |
| 162 return data_size == file_util::WriteFile(path, output.data(), data_size); | 162 return data_size == file_util::WriteFile(path, output.data(), data_size); |
| 163 } | 163 } |
| 164 | 164 |
| 165 } // namespace task_profiler | 165 } // namespace task_profiler |
| OLD | NEW |