| 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/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "base/tracked_objects.h" | 11 #include "base/tracked_objects.h" |
| 12 #include "chrome/common/chrome_content_client.h" | 12 #include "chrome/common/chrome_content_client.h" |
| 13 #include "content/public/common/process_type.h" | 13 #include "content/public/common/process_type.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 using base::DictionaryValue; | 16 using base::DictionaryValue; |
| 17 using base::ListValue; | 17 using base::ListValue; |
| 18 using base::Value; | 18 using base::Value; |
| 19 using tracked_objects::BirthOnThreadSnapshot; | 19 using tracked_objects::BirthOnThreadSnapshot; |
| 20 using tracked_objects::DeathDataSnapshot; | 20 using tracked_objects::DeathDataSnapshot; |
| 21 using tracked_objects::LocationSnapshot; | 21 using tracked_objects::LocationSnapshot; |
| 22 using tracked_objects::ParentChildPairSnapshot; | |
| 23 using tracked_objects::TaskSnapshot; | 22 using tracked_objects::TaskSnapshot; |
| 24 using tracked_objects::ProcessDataPhaseSnapshot; | 23 using tracked_objects::ProcessDataPhaseSnapshot; |
| 25 | 24 |
| 26 namespace { | 25 namespace { |
| 27 | 26 |
| 28 // Re-serializes the |location| into |dictionary|. | 27 // Re-serializes the |location| into |dictionary|. |
| 29 void LocationSnapshotToValue(const LocationSnapshot& location, | 28 void LocationSnapshotToValue(const LocationSnapshot& location, |
| 30 base::DictionaryValue* dictionary) { | 29 base::DictionaryValue* dictionary) { |
| 31 dictionary->SetString("file_name", location.file_name); | 30 dictionary->SetString("file_name", location.file_name); |
| 32 // Note: This function name is not escaped, and templates have less-than | 31 // Note: This function name is not escaped, and templates have less-than |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 for (const auto& task : process_data_phase.tasks) { | 87 for (const auto& task : process_data_phase.tasks) { |
| 89 scoped_ptr<base::DictionaryValue> snapshot(new base::DictionaryValue); | 88 scoped_ptr<base::DictionaryValue> snapshot(new base::DictionaryValue); |
| 90 TaskSnapshotToValue(task, snapshot.get()); | 89 TaskSnapshotToValue(task, snapshot.get()); |
| 91 tasks_list->Append(snapshot.release()); | 90 tasks_list->Append(snapshot.release()); |
| 92 } | 91 } |
| 93 dictionary->Set("list", tasks_list.release()); | 92 dictionary->Set("list", tasks_list.release()); |
| 94 | 93 |
| 95 dictionary->SetInteger("process_id", process_id); | 94 dictionary->SetInteger("process_id", process_id); |
| 96 dictionary->SetString("process_type", | 95 dictionary->SetString("process_type", |
| 97 content::GetProcessTypeNameInEnglish(process_type)); | 96 content::GetProcessTypeNameInEnglish(process_type)); |
| 98 | |
| 99 scoped_ptr<base::ListValue> descendants_list(new base::ListValue); | |
| 100 for (const auto& entry : process_data_phase.descendants) { | |
| 101 scoped_ptr<base::DictionaryValue> parent_child(new base::DictionaryValue); | |
| 102 BirthOnThreadSnapshotToValue(entry.parent, "parent", parent_child.get()); | |
| 103 BirthOnThreadSnapshotToValue(entry.child, "child", parent_child.get()); | |
| 104 descendants_list->Append(parent_child.release()); | |
| 105 } | |
| 106 dictionary->Set("descendants", descendants_list.release()); | |
| 107 } | 97 } |
| 108 | 98 |
| 109 } // namespace task_profiler | 99 } // namespace task_profiler |
| OLD | NEW |