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

Side by Side Diff: base/trace_event/process_memory_dump.cc

Issue 934323002: [tracing] Add a dump provider to dump process memory totals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months 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 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 "base/trace_event/process_memory_dump.h" 5 #include "base/trace_event/process_memory_dump.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/trace_event/process_memory_totals.h"
8 #include "base/values.h" 9 #include "base/values.h"
9 10
10 namespace base { 11 namespace base {
11 namespace trace_event { 12 namespace trace_event {
12 13
13 ProcessMemoryDump::ProcessMemoryDump() { 14 ProcessMemoryDump::ProcessMemoryDump() {
14 } 15 }
15 16
16 ProcessMemoryDump::~ProcessMemoryDump() { 17 ProcessMemoryDump::~ProcessMemoryDump() {
17 } 18 }
18 19
20 void ProcessMemoryDump::SetProcessTotals(scoped_ptr<ProcessMemoryTotals> pmt) {
21 process_totals_ = pmt.Pass();
22 }
23
19 void ProcessMemoryDump::AppendAsTraceFormat(std::string* out) const { 24 void ProcessMemoryDump::AppendAsTraceFormat(std::string* out) const {
20 // Build up the [dumper name] -> [serialized snapshot] JSON dictionary. 25 // Build up the [dumper name] -> [serialized snapshot] JSON dictionary.
21 DictionaryValue dict; 26 DictionaryValue dict;
22 std::string json_dict; 27 std::string json_dict;
23 // TODO(primiano): this will append here the actual dumps from the dumpers. 28
29 if (process_totals_)
30 dict.Set("process_totals", process_totals_->AsValue());
31
24 base::JSONWriter::Write(&dict, &json_dict); 32 base::JSONWriter::Write(&dict, &json_dict);
25 *out += json_dict; 33 *out += json_dict;
26 } 34 }
27 35
28 } // namespace trace_event 36 } // namespace trace_event
29 } // namespace base 37 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698