Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(477)

Side by Side Diff: chrome/browser/task_profiler/task_profiler_data_serializer.cc

Issue 2488073002: Reuse ThreadData instances associated with terminated named threads. (Closed)
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 void BirthOnThreadSnapshotToValue(const BirthOnThreadSnapshot& birth, 44 void BirthOnThreadSnapshotToValue(const BirthOnThreadSnapshot& birth,
45 const std::string& prefix, 45 const std::string& prefix,
46 base::DictionaryValue* dictionary) { 46 base::DictionaryValue* dictionary) {
47 DCHECK(!prefix.empty()); 47 DCHECK(!prefix.empty());
48 48
49 std::unique_ptr<base::DictionaryValue> location_value( 49 std::unique_ptr<base::DictionaryValue> location_value(
50 new base::DictionaryValue); 50 new base::DictionaryValue);
51 LocationSnapshotToValue(birth.location, location_value.get()); 51 LocationSnapshotToValue(birth.location, location_value.get());
52 dictionary->Set(prefix + "_location", location_value.release()); 52 dictionary->Set(prefix + "_location", location_value.release());
53 53
54 dictionary->Set(prefix + "_thread", new base::StringValue(birth.thread_name)); 54 dictionary->Set(prefix + "_thread",
55 new base::StringValue(birth.sanitized_thread_name));
55 } 56 }
56 57
57 // Re-serializes the |death_data| into |dictionary|. 58 // Re-serializes the |death_data| into |dictionary|.
58 void DeathDataSnapshotToValue(const DeathDataSnapshot& death_data, 59 void DeathDataSnapshotToValue(const DeathDataSnapshot& death_data,
59 base::DictionaryValue* dictionary) { 60 base::DictionaryValue* dictionary) {
60 dictionary->SetInteger("count", death_data.count); 61 dictionary->SetInteger("count", death_data.count);
61 dictionary->SetInteger("run_ms", death_data.run_duration_sum); 62 dictionary->SetInteger("run_ms", death_data.run_duration_sum);
62 dictionary->SetInteger("run_ms_max", death_data.run_duration_max); 63 dictionary->SetInteger("run_ms_max", death_data.run_duration_max);
63 dictionary->SetInteger("run_ms_sample", death_data.run_duration_sample); 64 dictionary->SetInteger("run_ms_sample", death_data.run_duration_sample);
64 dictionary->SetInteger("queue_ms", death_data.queue_duration_sum); 65 dictionary->SetInteger("queue_ms", death_data.queue_duration_sum);
(...skipping 11 matching lines...) Expand all
76 77
77 // Re-serializes the |snapshot| into |dictionary|. 78 // Re-serializes the |snapshot| into |dictionary|.
78 void TaskSnapshotToValue(const TaskSnapshot& snapshot, 79 void TaskSnapshotToValue(const TaskSnapshot& snapshot,
79 base::DictionaryValue* dictionary) { 80 base::DictionaryValue* dictionary) {
80 BirthOnThreadSnapshotToValue(snapshot.birth, "birth", dictionary); 81 BirthOnThreadSnapshotToValue(snapshot.birth, "birth", dictionary);
81 82
82 std::unique_ptr<base::DictionaryValue> death_data(new base::DictionaryValue); 83 std::unique_ptr<base::DictionaryValue> death_data(new base::DictionaryValue);
83 DeathDataSnapshotToValue(snapshot.death_data, death_data.get()); 84 DeathDataSnapshotToValue(snapshot.death_data, death_data.get());
84 dictionary->Set("death_data", death_data.release()); 85 dictionary->Set("death_data", death_data.release());
85 86
86 dictionary->SetString("death_thread", snapshot.death_thread_name); 87 dictionary->SetString("death_thread", snapshot.death_sanitized_thread_name);
87 } 88 }
88 89
89 int AsChromeProcessType( 90 int AsChromeProcessType(
90 metrics::ProfilerEventProto::TrackedObject::ProcessType process_type) { 91 metrics::ProfilerEventProto::TrackedObject::ProcessType process_type) {
91 switch (process_type) { 92 switch (process_type) {
92 case metrics::ProfilerEventProto::TrackedObject::UNKNOWN: 93 case metrics::ProfilerEventProto::TrackedObject::UNKNOWN:
93 case metrics::ProfilerEventProto::TrackedObject::PLUGIN: 94 case metrics::ProfilerEventProto::TrackedObject::PLUGIN:
94 return content::PROCESS_TYPE_UNKNOWN; 95 return content::PROCESS_TYPE_UNKNOWN;
95 case metrics::ProfilerEventProto::TrackedObject::BROWSER: 96 case metrics::ProfilerEventProto::TrackedObject::BROWSER:
96 return content::PROCESS_TYPE_BROWSER; 97 return content::PROCESS_TYPE_BROWSER;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 tasks_list->Append(std::move(snapshot)); 139 tasks_list->Append(std::move(snapshot));
139 } 140 }
140 dictionary->Set("list", tasks_list.release()); 141 dictionary->Set("list", tasks_list.release());
141 142
142 dictionary->SetInteger("process_id", process_id); 143 dictionary->SetInteger("process_id", process_id);
143 dictionary->SetString("process_type", content::GetProcessTypeNameInEnglish( 144 dictionary->SetString("process_type", content::GetProcessTypeNameInEnglish(
144 AsChromeProcessType(process_type))); 145 AsChromeProcessType(process_type)));
145 } 146 }
146 147
147 } // namespace task_profiler 148 } // namespace task_profiler
OLDNEW
« no previous file with comments | « base/tracked_objects_unittest.cc ('k') | chrome/browser/task_profiler/task_profiler_data_serializer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698