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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 pending_trace_log_status_ack_count_(0), | 168 pending_trace_log_status_ack_count_(0), |
169 maximum_trace_buffer_usage_(0), | 169 maximum_trace_buffer_usage_(0), |
170 approximate_event_count_(0), | 170 approximate_event_count_(0), |
171 // Tracing may have been enabled by ContentMainRunner if kTraceStartup | 171 // Tracing may have been enabled by ContentMainRunner if kTraceStartup |
172 // is specified in command line. | 172 // is specified in command line. |
173 #if defined(OS_CHROMEOS) || defined(OS_WIN) | 173 #if defined(OS_CHROMEOS) || defined(OS_WIN) |
174 is_system_tracing_(false), | 174 is_system_tracing_(false), |
175 #endif | 175 #endif |
176 is_recording_(TraceLog::GetInstance()->IsEnabled()), | 176 is_recording_(TraceLog::GetInstance()->IsEnabled()), |
177 is_monitoring_(false) { | 177 is_monitoring_(false) { |
| 178 base::trace_event::MemoryDumpManager::GetInstance()->SetDelegate(this); |
178 } | 179 } |
179 | 180 |
180 TracingControllerImpl::~TracingControllerImpl() { | 181 TracingControllerImpl::~TracingControllerImpl() { |
181 // This is a Leaky instance. | 182 // This is a Leaky instance. |
182 NOTREACHED(); | 183 NOTREACHED(); |
183 } | 184 } |
184 | 185 |
185 TracingControllerImpl* TracingControllerImpl::GetInstance() { | 186 TracingControllerImpl* TracingControllerImpl::GetInstance() { |
186 return g_controller.Pointer(); | 187 return g_controller.Pointer(); |
187 } | 188 } |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 DCHECK(tracing_uis_.find(tracing_ui) == tracing_uis_.end()); | 873 DCHECK(tracing_uis_.find(tracing_ui) == tracing_uis_.end()); |
873 tracing_uis_.insert(tracing_ui); | 874 tracing_uis_.insert(tracing_ui); |
874 } | 875 } |
875 | 876 |
876 void TracingControllerImpl::UnregisterTracingUI(TracingUI* tracing_ui) { | 877 void TracingControllerImpl::UnregisterTracingUI(TracingUI* tracing_ui) { |
877 std::set<TracingUI*>::iterator it = tracing_uis_.find(tracing_ui); | 878 std::set<TracingUI*>::iterator it = tracing_uis_.find(tracing_ui); |
878 DCHECK(it != tracing_uis_.end()); | 879 DCHECK(it != tracing_uis_.end()); |
879 tracing_uis_.erase(it); | 880 tracing_uis_.erase(it); |
880 } | 881 } |
881 | 882 |
| 883 void TracingControllerImpl::RequestGlobalMemoryDump( |
| 884 const base::trace_event::MemoryDumpRequestArgs& args, |
| 885 const base::trace_event::MemoryDumpCallback& callback) { |
| 886 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 887 BrowserThread::PostTask( |
| 888 BrowserThread::UI, FROM_HERE, |
| 889 base::Bind(&TracingControllerImpl::RequestGlobalMemoryDump, |
| 890 base::Unretained(this), args, callback)); |
| 891 return; |
| 892 } |
| 893 // TODO(primiano): send a local dump request to each of the child processes |
| 894 // and do the bookkeeping to keep track of the outstanding requests. |
| 895 // Also, at this point, this should check for collisions and bail out if a |
| 896 // global dump is requested while another is already in progress. |
| 897 NOTIMPLEMENTED(); |
| 898 } |
| 899 |
| 900 void TracingControllerImpl::OnProcessMemoryDumpResponse( |
| 901 TraceMessageFilter* trace_message_filter, |
| 902 uint64 dump_guid, |
| 903 bool success) { |
| 904 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 905 BrowserThread::PostTask( |
| 906 BrowserThread::UI, FROM_HERE, |
| 907 base::Bind(&TracingControllerImpl::OnProcessMemoryDumpResponse, |
| 908 base::Unretained(this), |
| 909 make_scoped_refptr(trace_message_filter), dump_guid, |
| 910 success)); |
| 911 return; |
| 912 } |
| 913 // TODO(primiano): update the bookkeeping structs and, if this was the |
| 914 // response from the last pending child, fire the completion callback, which |
| 915 // in turn will cause a GlobalMemoryDumpResponse message to be sent back to |
| 916 // the child, if this global dump was NOT initiated by the browser. |
| 917 NOTIMPLEMENTED(); |
| 918 } |
| 919 |
882 void TracingControllerImpl::OnMonitoringStateChanged(bool is_monitoring) { | 920 void TracingControllerImpl::OnMonitoringStateChanged(bool is_monitoring) { |
883 if (is_monitoring_ == is_monitoring) | 921 if (is_monitoring_ == is_monitoring) |
884 return; | 922 return; |
885 | 923 |
886 is_monitoring_ = is_monitoring; | 924 is_monitoring_ = is_monitoring; |
887 #if !defined(OS_ANDROID) | 925 #if !defined(OS_ANDROID) |
888 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); | 926 for (std::set<TracingUI*>::iterator it = tracing_uis_.begin(); |
889 it != tracing_uis_.end(); it++) { | 927 it != tracing_uis_.end(); it++) { |
890 (*it)->OnMonitoringStateChanged(is_monitoring); | 928 (*it)->OnMonitoringStateChanged(is_monitoring); |
891 } | 929 } |
892 #endif | 930 #endif |
893 } | 931 } |
894 | 932 |
895 } // namespace content | 933 } // namespace content |
OLD | NEW |