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

Side by Side Diff: content/browser/tracing/tracing_controller_impl.cc

Issue 1417003003: [tracing] Dump child processes' memory metrics in browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web_cache2_base
Patch Set: dNits. Created 5 years, 1 month 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "content/browser/tracing/tracing_controller_impl.h" 4 #include "content/browser/tracing/tracing_controller_impl.h"
5 5
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/json/string_escape.h" 8 #include "base/json/string_escape.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
12 #include "components/tracing/process_metrics_memory_dump_manager.h"
12 #include "content/browser/tracing/file_tracing_provider_impl.h" 13 #include "content/browser/tracing/file_tracing_provider_impl.h"
13 #include "content/browser/tracing/power_tracing_agent.h" 14 #include "content/browser/tracing/power_tracing_agent.h"
14 #include "content/browser/tracing/trace_message_filter.h" 15 #include "content/browser/tracing/trace_message_filter.h"
15 #include "content/browser/tracing/tracing_ui.h" 16 #include "content/browser/tracing/tracing_ui.h"
16 #include "content/common/child_process_messages.h" 17 #include "content/common/child_process_messages.h"
17 #include "content/public/browser/browser_message_filter.h" 18 #include "content/public/browser/browser_message_filter.h"
18 #include "content/public/common/child_process_host.h" 19 #include "content/public/common/child_process_host.h"
19 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
20 21
21 #if defined(OS_CHROMEOS) 22 #if defined(OS_CHROMEOS)
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 void TracingControllerImpl::AddTraceMessageFilter( 483 void TracingControllerImpl::AddTraceMessageFilter(
483 TraceMessageFilter* trace_message_filter) { 484 TraceMessageFilter* trace_message_filter) {
484 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 485 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
485 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 486 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
486 base::Bind(&TracingControllerImpl::AddTraceMessageFilter, 487 base::Bind(&TracingControllerImpl::AddTraceMessageFilter,
487 base::Unretained(this), 488 base::Unretained(this),
488 make_scoped_refptr(trace_message_filter))); 489 make_scoped_refptr(trace_message_filter)));
489 return; 490 return;
490 } 491 }
491 492
493 tracing::ProcessMetricsMemoryDumpManager::GetInstance()->RegisterForProcess(
494 trace_message_filter->peer_pid());
Primiano Tucci (use gerrit) 2015/11/17 10:44:13 Shouldn't this be >PeerHandle() ?
ssid 2015/11/17 13:55:06 Done.
495
492 trace_message_filters_.insert(trace_message_filter); 496 trace_message_filters_.insert(trace_message_filter);
493 if (can_cancel_watch_event()) { 497 if (can_cancel_watch_event()) {
494 trace_message_filter->SendSetWatchEvent(watch_category_name_, 498 trace_message_filter->SendSetWatchEvent(watch_category_name_,
495 watch_event_name_); 499 watch_event_name_);
496 } 500 }
497 if (can_disable_recording()) { 501 if (can_disable_recording()) {
498 trace_message_filter->SendBeginTracing( 502 trace_message_filter->SendBeginTracing(
499 TraceLog::GetInstance()->GetCurrentTraceConfig()); 503 TraceLog::GetInstance()->GetCurrentTraceConfig());
500 } 504 }
501 if (can_disable_monitoring()) { 505 if (can_disable_monitoring()) {
502 trace_message_filter->SendEnableMonitoring( 506 trace_message_filter->SendEnableMonitoring(
503 TraceLog::GetInstance()->GetCurrentTraceConfig()); 507 TraceLog::GetInstance()->GetCurrentTraceConfig());
504 } 508 }
505 509
506 FOR_EACH_OBSERVER(TraceMessageFilterObserver, trace_message_filter_observers_, 510 FOR_EACH_OBSERVER(TraceMessageFilterObserver, trace_message_filter_observers_,
507 OnTraceMessageFilterAdded(trace_message_filter)); 511 OnTraceMessageFilterAdded(trace_message_filter));
508 } 512 }
509 513
510 void TracingControllerImpl::RemoveTraceMessageFilter( 514 void TracingControllerImpl::RemoveTraceMessageFilter(
511 TraceMessageFilter* trace_message_filter) { 515 TraceMessageFilter* trace_message_filter) {
512 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 516 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
513 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 517 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
514 base::Bind(&TracingControllerImpl::RemoveTraceMessageFilter, 518 base::Bind(&TracingControllerImpl::RemoveTraceMessageFilter,
515 base::Unretained(this), 519 base::Unretained(this),
516 make_scoped_refptr(trace_message_filter))); 520 make_scoped_refptr(trace_message_filter)));
517 return; 521 return;
518 } 522 }
519 523
524 tracing::ProcessMetricsMemoryDumpManager::GetInstance()->UnregisterForProcess(
525 trace_message_filter->peer_pid());
Primiano Tucci (use gerrit) 2015/11/17 10:44:12 ditto
ssid 2015/11/17 13:55:06 Done.
526
520 // If a filter is removed while a response from that filter is pending then 527 // If a filter is removed while a response from that filter is pending then
521 // simulate the response. Otherwise the response count will be wrong and the 528 // simulate the response. Otherwise the response count will be wrong and the
522 // completion callback will never be executed. 529 // completion callback will never be executed.
523 if (pending_disable_recording_ack_count_ > 0) { 530 if (pending_disable_recording_ack_count_ > 0) {
524 TraceMessageFilterSet::const_iterator it = 531 TraceMessageFilterSet::const_iterator it =
525 pending_disable_recording_filters_.find(trace_message_filter); 532 pending_disable_recording_filters_.find(trace_message_filter);
526 if (it != pending_disable_recording_filters_.end()) { 533 if (it != pending_disable_recording_filters_.end()) {
527 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 534 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
528 base::Bind(&TracingControllerImpl::OnDisableRecordingAcked, 535 base::Bind(&TracingControllerImpl::OnDisableRecordingAcked,
529 base::Unretained(this), 536 base::Unretained(this),
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 is_monitoring_ = is_monitoring; 949 is_monitoring_ = is_monitoring;
943 #if !defined(OS_ANDROID) 950 #if !defined(OS_ANDROID)
944 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); 951 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin();
945 it != tracing_uis_.end(); it++) { 952 it != tracing_uis_.end(); it++) {
946 (*it)->OnMonitoringStateChanged(is_monitoring); 953 (*it)->OnMonitoringStateChanged(is_monitoring);
947 } 954 }
948 #endif 955 #endif
949 } 956 }
950 957
951 } // namespace content 958 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698