| OLD | NEW |
| 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" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 pending_memory_dump_ack_count_(0), | 52 pending_memory_dump_ack_count_(0), |
| 53 failed_memory_dump_count_(0), | 53 failed_memory_dump_count_(0), |
| 54 // Tracing may have been enabled by ContentMainRunner if kTraceStartup | 54 // Tracing may have been enabled by ContentMainRunner if kTraceStartup |
| 55 // is specified in command line. | 55 // is specified in command line. |
| 56 #if defined(OS_CHROMEOS) || defined(OS_WIN) | 56 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
| 57 is_system_tracing_(false), | 57 is_system_tracing_(false), |
| 58 #endif | 58 #endif |
| 59 is_recording_(TraceLog::GetInstance()->IsEnabled()), | 59 is_recording_(TraceLog::GetInstance()->IsEnabled()), |
| 60 is_monitoring_(false), | 60 is_monitoring_(false), |
| 61 is_power_tracing_(false) { | 61 is_power_tracing_(false) { |
| 62 base::trace_event::MemoryDumpManager::GetInstance()->SetDelegate(this); | 62 base::trace_event::MemoryDumpManager::GetInstance()->Initialize( |
| 63 this /* delegate */, true /* is_coordinator */); |
| 63 | 64 |
| 64 // Deliberately leaked, like this class. | 65 // Deliberately leaked, like this class. |
| 65 base::FileTracing::SetProvider(new FileTracingProviderImpl); | 66 base::FileTracing::SetProvider(new FileTracingProviderImpl); |
| 66 } | 67 } |
| 67 | 68 |
| 68 TracingControllerImpl::~TracingControllerImpl() { | 69 TracingControllerImpl::~TracingControllerImpl() { |
| 69 // This is a Leaky instance. | 70 // This is a Leaky instance. |
| 70 NOTREACHED(); | 71 NOTREACHED(); |
| 71 } | 72 } |
| 72 | 73 |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 // If there are no child processes we are just done. | 840 // If there are no child processes we are just done. |
| 840 if (pending_memory_dump_ack_count_ == 1) | 841 if (pending_memory_dump_ack_count_ == 1) |
| 841 return; | 842 return; |
| 842 | 843 |
| 843 pending_memory_dump_filters_ = trace_message_filters_; | 844 pending_memory_dump_filters_ = trace_message_filters_; |
| 844 | 845 |
| 845 for (const scoped_refptr<TraceMessageFilter>& tmf : trace_message_filters_) | 846 for (const scoped_refptr<TraceMessageFilter>& tmf : trace_message_filters_) |
| 846 tmf->SendProcessMemoryDumpRequest(args); | 847 tmf->SendProcessMemoryDumpRequest(args); |
| 847 } | 848 } |
| 848 | 849 |
| 849 bool TracingControllerImpl::IsCoordinatorProcess() const { | |
| 850 return true; | |
| 851 } | |
| 852 | |
| 853 uint64 TracingControllerImpl::GetTracingProcessId() const { | 850 uint64 TracingControllerImpl::GetTracingProcessId() const { |
| 854 return ChildProcessHost::kBrowserTracingProcessId; | 851 return ChildProcessHost::kBrowserTracingProcessId; |
| 855 } | 852 } |
| 856 | 853 |
| 857 void TracingControllerImpl::AddTraceMessageFilterObserver( | 854 void TracingControllerImpl::AddTraceMessageFilterObserver( |
| 858 TraceMessageFilterObserver* observer) { | 855 TraceMessageFilterObserver* observer) { |
| 859 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 856 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 860 trace_message_filter_observers_.AddObserver(observer); | 857 trace_message_filter_observers_.AddObserver(observer); |
| 861 | 858 |
| 862 for (auto& filter : trace_message_filters_) | 859 for (auto& filter : trace_message_filters_) |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 is_monitoring_ = is_monitoring; | 935 is_monitoring_ = is_monitoring; |
| 939 #if !defined(OS_ANDROID) | 936 #if !defined(OS_ANDROID) |
| 940 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); | 937 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); |
| 941 it != tracing_uis_.end(); it++) { | 938 it != tracing_uis_.end(); it++) { |
| 942 (*it)->OnMonitoringStateChanged(is_monitoring); | 939 (*it)->OnMonitoringStateChanged(is_monitoring); |
| 943 } | 940 } |
| 944 #endif | 941 #endif |
| 945 } | 942 } |
| 946 | 943 |
| 947 } // namespace content | 944 } // namespace content |
| OLD | NEW |