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

Side by Side Diff: components/tracing/child_trace_message_filter.cc

Issue 1329273002: [tracing] Send smaps file desciptor to child process for tracing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 2 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
« no previous file with comments | « components/tracing/child_trace_message_filter.h ('k') | components/tracing/tracing_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/tracing/child_trace_message_filter.h" 5 #include "components/tracing/child_trace_message_filter.h"
6 6
7 #include "base/metrics/statistics_recorder.h" 7 #include "base/metrics/statistics_recorder.h"
8 #include "base/trace_event/trace_event.h" 8 #include "base/trace_event/trace_event.h"
9 #include "components/tracing/child_memory_dump_manager_delegate_impl.h" 9 #include "components/tracing/child_memory_dump_manager_delegate_impl.h"
10 #include "components/tracing/tracing_messages.h"
11 #include "ipc/ipc_channel.h" 10 #include "ipc/ipc_channel.h"
12 11
13 using base::trace_event::TraceLog; 12 using base::trace_event::TraceLog;
14 13
15 namespace tracing { 14 namespace tracing {
16 15
17 namespace { 16 namespace {
18 17
19 const int kMinTimeBetweenHistogramChangesInSeconds = 10; 18 const int kMinTimeBetweenHistogramChangesInSeconds = 10;
20 19
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 IPC_MESSAGE_UNHANDLED(handled = false) 61 IPC_MESSAGE_UNHANDLED(handled = false)
63 IPC_END_MESSAGE_MAP() 62 IPC_END_MESSAGE_MAP()
64 return handled; 63 return handled;
65 } 64 }
66 65
67 ChildTraceMessageFilter::~ChildTraceMessageFilter() {} 66 ChildTraceMessageFilter::~ChildTraceMessageFilter() {}
68 67
69 void ChildTraceMessageFilter::OnBeginTracing( 68 void ChildTraceMessageFilter::OnBeginTracing(
70 const std::string& trace_config_str, 69 const std::string& trace_config_str,
71 base::TraceTicks browser_time, 70 base::TraceTicks browser_time,
72 uint64 tracing_process_id) { 71 TracingMsg_MemoryTracingInfo memory_tracing_info) {
73 #if defined(__native_client__) 72 #if defined(__native_client__)
74 // NaCl and system times are offset by a bit, so subtract some time from 73 // NaCl and system times are offset by a bit, so subtract some time from
75 // the captured timestamps. The value might be off by a bit due to messaging 74 // the captured timestamps. The value might be off by a bit due to messaging
76 // latency. 75 // latency.
77 base::TimeDelta time_offset = base::TraceTicks::Now() - browser_time; 76 base::TimeDelta time_offset = base::TraceTicks::Now() - browser_time;
78 TraceLog::GetInstance()->SetTimeOffset(time_offset); 77 TraceLog::GetInstance()->SetTimeOffset(time_offset);
79 #endif 78 #endif
80 ChildMemoryDumpManagerDelegateImpl::GetInstance()->set_tracing_process_id( 79 ChildMemoryDumpManagerDelegateImpl::GetInstance()->SetMemoryTracingInfo(
81 tracing_process_id); 80 memory_tracing_info);
82 TraceLog::GetInstance()->SetEnabled( 81 TraceLog::GetInstance()->SetEnabled(
83 base::trace_event::TraceConfig(trace_config_str), 82 base::trace_event::TraceConfig(trace_config_str),
84 base::trace_event::TraceLog::RECORDING_MODE); 83 base::trace_event::TraceLog::RECORDING_MODE);
85 } 84 }
86 85
87 void ChildTraceMessageFilter::OnEndTracing() { 86 void ChildTraceMessageFilter::OnEndTracing() {
87 ChildMemoryDumpManagerDelegateImpl::GetInstance()->ResetMemoryTracingInfo();
88
88 TraceLog::GetInstance()->SetDisabled(); 89 TraceLog::GetInstance()->SetDisabled();
89 90
90 // Flush will generate one or more callbacks to OnTraceDataCollected 91 // Flush will generate one or more callbacks to OnTraceDataCollected
91 // synchronously or asynchronously. EndTracingAck will be sent in the last 92 // synchronously or asynchronously. EndTracingAck will be sent in the last
92 // OnTraceDataCollected. We are already on the IO thread, so the 93 // OnTraceDataCollected. We are already on the IO thread, so the
93 // OnTraceDataCollected calls will not be deferred. 94 // OnTraceDataCollected calls will not be deferred.
94 TraceLog::GetInstance()->Flush( 95 TraceLog::GetInstance()->Flush(
95 base::Bind(&ChildTraceMessageFilter::OnTraceDataCollected, this)); 96 base::Bind(&ChildTraceMessageFilter::OnTraceDataCollected, this));
96
97 ChildMemoryDumpManagerDelegateImpl::GetInstance()->set_tracing_process_id(
98 base::trace_event::MemoryDumpManager::kInvalidTracingProcessId);
99 } 97 }
100 98
101 void ChildTraceMessageFilter::OnCancelTracing() { 99 void ChildTraceMessageFilter::OnCancelTracing() {
102 TraceLog::GetInstance()->CancelTracing( 100 TraceLog::GetInstance()->CancelTracing(
103 base::Bind(&ChildTraceMessageFilter::OnTraceDataCollected, this)); 101 base::Bind(&ChildTraceMessageFilter::OnTraceDataCollected, this));
104 } 102 }
105 103
106 void ChildTraceMessageFilter::OnEnableMonitoring( 104 void ChildTraceMessageFilter::OnEnableMonitoring(
107 const std::string& trace_config_str, 105 const std::string& trace_config_str,
108 base::TraceTicks browser_time) { 106 base::TraceTicks browser_time) {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 } 303 }
306 } 304 }
307 305
308 void ChildTraceMessageFilter::OnClearUMACallback( 306 void ChildTraceMessageFilter::OnClearUMACallback(
309 const std::string& histogram_name) { 307 const std::string& histogram_name) {
310 histogram_last_changed_ = base::Time(); 308 histogram_last_changed_ = base::Time();
311 base::StatisticsRecorder::ClearCallback(histogram_name); 309 base::StatisticsRecorder::ClearCallback(histogram_name);
312 } 310 }
313 311
314 } // namespace tracing 312 } // namespace tracing
OLDNEW
« no previous file with comments | « components/tracing/child_trace_message_filter.h ('k') | components/tracing/tracing_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698