Index: chrome/browser/task_profiler/task_profiler_data_serializer_unittest.cc |
diff --git a/chrome/browser/task_profiler/task_profiler_data_serializer_unittest.cc b/chrome/browser/task_profiler/task_profiler_data_serializer_unittest.cc |
index 8067b46e615e72842eadbc84bce3a44f56c6b83c..c9a72e6cae41d0eb05149f7b7bf75864b40ed12a 100644 |
--- a/chrome/browser/task_profiler/task_profiler_data_serializer_unittest.cc |
+++ b/chrome/browser/task_profiler/task_profiler_data_serializer_unittest.cc |
@@ -16,17 +16,14 @@ |
namespace { |
-std::string GetProcessIdString() { |
- return base::IntToString(base::GetCurrentProcId()); |
-} |
- |
void ExpectSerialization( |
- const tracked_objects::ProcessDataSnapshot& process_data, |
+ const tracked_objects::ProcessDataPhaseSnapshot& process_data_phase, |
+ base::ProcessId process_id, |
int process_type, |
const std::string& expected_json) { |
base::DictionaryValue serialized_value; |
task_profiler::TaskProfilerDataSerializer::ToValue( |
- process_data, process_type, &serialized_value); |
+ process_data_phase, process_id, process_type, &serialized_value); |
std::string serialized_json; |
base::JSONWriter::Write(&serialized_value, &serialized_json); |
@@ -40,22 +37,22 @@ void ExpectSerialization( |
TEST(TaskProfilerDataSerializerTest, SerializeProcessDataToJson) { |
{ |
// Empty data. |
- tracked_objects::ProcessDataSnapshot process_data; |
+ tracked_objects::ProcessDataPhaseSnapshot process_data_phase; |
int process_type = content::PROCESS_TYPE_BROWSER; |
- ExpectSerialization(process_data, process_type, |
+ ExpectSerialization(process_data_phase, 239, process_type, |
"{" |
- "\"descendants\":[" |
- "]," |
- "\"list\":[" |
- "]," |
- "\"process_id\":" + GetProcessIdString() + "," |
- "\"process_type\":\"Browser\"" |
+ "\"descendants\":[" |
+ "]," |
+ "\"list\":[" |
+ "]," |
+ "\"process_id\":239," |
+ "\"process_type\":\"Browser\"" |
"}"); |
} |
{ |
// Non-empty data. |
- tracked_objects::ProcessDataSnapshot process_data; |
+ tracked_objects::ProcessDataPhaseSnapshot process_data_phase; |
tracked_objects::BirthOnThreadSnapshot parent; |
parent.location.file_name = "path/to/foo.cc"; |
@@ -71,91 +68,92 @@ TEST(TaskProfilerDataSerializerTest, SerializeProcessDataToJson) { |
// Add a snapshot. |
- process_data.tasks.push_back(tracked_objects::TaskSnapshot()); |
- process_data.tasks.back().birth = parent; |
- process_data.tasks.back().death_data.count = 37; |
- process_data.tasks.back().death_data.run_duration_max = 5; |
- process_data.tasks.back().death_data.run_duration_sample = 3; |
- process_data.tasks.back().death_data.run_duration_sum = 17; |
- process_data.tasks.back().death_data.queue_duration_max = 53; |
- process_data.tasks.back().death_data.queue_duration_sample = 13; |
- process_data.tasks.back().death_data.queue_duration_sum = 79; |
- process_data.tasks.back().death_thread_name = "WorkerPool/-1340960768"; |
+ process_data_phase.tasks.push_back(tracked_objects::TaskSnapshot()); |
+ process_data_phase.tasks.back().birth = parent; |
+ process_data_phase.tasks.back().death_data.count = 37; |
+ process_data_phase.tasks.back().death_data.run_duration_max = 5; |
+ process_data_phase.tasks.back().death_data.run_duration_sample = 3; |
+ process_data_phase.tasks.back().death_data.run_duration_sum = 17; |
+ process_data_phase.tasks.back().death_data.queue_duration_max = 53; |
+ process_data_phase.tasks.back().death_data.queue_duration_sample = 13; |
+ process_data_phase.tasks.back().death_data.queue_duration_sum = 79; |
+ process_data_phase.tasks.back().death_thread_name = |
+ "WorkerPool/-1340960768"; |
// Add a second snapshot. |
- process_data.tasks.push_back(tracked_objects::TaskSnapshot()); |
- process_data.tasks.back().birth = child; |
- process_data.tasks.back().death_data.count = 41; |
- process_data.tasks.back().death_data.run_duration_max = 205; |
- process_data.tasks.back().death_data.run_duration_sample = 203; |
- process_data.tasks.back().death_data.run_duration_sum = 2017; |
- process_data.tasks.back().death_data.queue_duration_max = 2053; |
- process_data.tasks.back().death_data.queue_duration_sample = 2013; |
- process_data.tasks.back().death_data.queue_duration_sum = 2079; |
- process_data.tasks.back().death_thread_name = "PAC thread #3"; |
+ process_data_phase.tasks.push_back(tracked_objects::TaskSnapshot()); |
+ process_data_phase.tasks.back().birth = child; |
+ process_data_phase.tasks.back().death_data.count = 41; |
+ process_data_phase.tasks.back().death_data.run_duration_max = 205; |
+ process_data_phase.tasks.back().death_data.run_duration_sample = 203; |
+ process_data_phase.tasks.back().death_data.run_duration_sum = 2017; |
+ process_data_phase.tasks.back().death_data.queue_duration_max = 2053; |
+ process_data_phase.tasks.back().death_data.queue_duration_sample = 2013; |
+ process_data_phase.tasks.back().death_data.queue_duration_sum = 2079; |
+ process_data_phase.tasks.back().death_thread_name = "PAC thread #3"; |
// Add a parent-child pair. |
- process_data.descendants.push_back( |
+ process_data_phase.descendants.push_back( |
tracked_objects::ParentChildPairSnapshot()); |
- process_data.descendants.back().parent = parent; |
- process_data.descendants.back().child = child; |
+ process_data_phase.descendants.back().parent = parent; |
+ process_data_phase.descendants.back().child = child; |
int process_type = content::PROCESS_TYPE_RENDERER; |
- ExpectSerialization(process_data, process_type, |
- "{" |
- "\"descendants\":[" |
- "{" |
- "\"child_location\":{" |
- "\"file_name\":\"path/to/bar.cc\"," |
- "\"function_name\":\"FizzBoom\"," |
- "\"line_number\":433" |
- "}," |
- "\"child_thread\":\"Chrome_IOThread\"," |
- "\"parent_location\":{" |
- "\"file_name\":\"path/to/foo.cc\"," |
- "\"function_name\":\"WhizBang\"," |
- "\"line_number\":101" |
- "}," |
- "\"parent_thread\":\"CrBrowserMain\"" |
- "}" |
- "]," |
- "\"list\":[{" |
- "\"birth_location\":{" |
- "\"file_name\":\"path/to/foo.cc\"," |
- "\"function_name\":\"WhizBang\"," |
- "\"line_number\":101" |
- "}," |
- "\"birth_thread\":\"CrBrowserMain\"," |
- "\"death_data\":{" |
- "\"count\":37," |
- "\"queue_ms\":79," |
- "\"queue_ms_max\":53," |
- "\"queue_ms_sample\":13," |
- "\"run_ms\":17," |
- "\"run_ms_max\":5," |
- "\"run_ms_sample\":3" |
- "}," |
- "\"death_thread\":\"WorkerPool/-1340960768\"" |
- "},{" |
- "\"birth_location\":{" |
- "\"file_name\":\"path/to/bar.cc\"," |
- "\"function_name\":\"FizzBoom\"," |
- "\"line_number\":433" |
- "}," |
- "\"birth_thread\":\"Chrome_IOThread\"," |
- "\"death_data\":{" |
- "\"count\":41," |
- "\"queue_ms\":2079," |
- "\"queue_ms_max\":2053," |
- "\"queue_ms_sample\":2013," |
- "\"run_ms\":2017," |
- "\"run_ms_max\":205," |
- "\"run_ms_sample\":203" |
- "}," |
- "\"death_thread\":\"PAC thread #3\"" |
- "}]," |
- "\"process_id\":" + GetProcessIdString() + "," |
- "\"process_type\":\"Tab\"" |
+ ExpectSerialization(process_data_phase, 239, process_type, |
+ "{" |
+ "\"descendants\":[" |
+ "{" |
+ "\"child_location\":{" |
+ "\"file_name\":\"path/to/bar.cc\"," |
+ "\"function_name\":\"FizzBoom\"," |
+ "\"line_number\":433" |
+ "}," |
+ "\"child_thread\":\"Chrome_IOThread\"," |
+ "\"parent_location\":{" |
+ "\"file_name\":\"path/to/foo.cc\"," |
+ "\"function_name\":\"WhizBang\"," |
+ "\"line_number\":101" |
+ "}," |
+ "\"parent_thread\":\"CrBrowserMain\"" |
+ "}" |
+ "]," |
+ "\"list\":[{" |
+ "\"birth_location\":{" |
+ "\"file_name\":\"path/to/foo.cc\"," |
+ "\"function_name\":\"WhizBang\"," |
+ "\"line_number\":101" |
+ "}," |
+ "\"birth_thread\":\"CrBrowserMain\"," |
+ "\"death_data\":{" |
+ "\"count\":37," |
+ "\"queue_ms\":79," |
+ "\"queue_ms_max\":53," |
+ "\"queue_ms_sample\":13," |
+ "\"run_ms\":17," |
+ "\"run_ms_max\":5," |
+ "\"run_ms_sample\":3" |
+ "}," |
+ "\"death_thread\":\"WorkerPool/-1340960768\"" |
+ "},{" |
+ "\"birth_location\":{" |
+ "\"file_name\":\"path/to/bar.cc\"," |
+ "\"function_name\":\"FizzBoom\"," |
+ "\"line_number\":433" |
+ "}," |
+ "\"birth_thread\":\"Chrome_IOThread\"," |
+ "\"death_data\":{" |
+ "\"count\":41," |
+ "\"queue_ms\":2079," |
+ "\"queue_ms_max\":2053," |
+ "\"queue_ms_sample\":2013," |
+ "\"run_ms\":2017," |
+ "\"run_ms_max\":205," |
+ "\"run_ms_sample\":203" |
+ "}," |
+ "\"death_thread\":\"PAC thread #3\"" |
+ "}]," |
+ "\"process_id\":239," |
+ "\"process_type\":\"Tab\"" |
"}"); |
} |
} |