| 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 <algorithm> | 6 #include <algorithm> |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 #include "content/browser/tracing/etw_tracing_agent_win.h" | 60 #include "content/browser/tracing/etw_tracing_agent_win.h" |
| 61 #endif | 61 #endif |
| 62 | 62 |
| 63 using base::trace_event::TraceLog; | 63 using base::trace_event::TraceLog; |
| 64 using base::trace_event::TraceConfig; | 64 using base::trace_event::TraceConfig; |
| 65 | 65 |
| 66 namespace content { | 66 namespace content { |
| 67 | 67 |
| 68 namespace { | 68 namespace { |
| 69 | 69 |
| 70 base::LazyInstance<TracingControllerImpl>::Leaky g_controller = | 70 base::LazyInstance<TracingControllerImpl>::Leaky g_tracing_controller = |
| 71 LAZY_INSTANCE_INITIALIZER; | 71 LAZY_INSTANCE_INITIALIZER; |
| 72 | 72 |
| 73 const char kChromeTracingAgentName[] = "chrome"; | 73 const char kChromeTracingAgentName[] = "chrome"; |
| 74 const char kETWTracingAgentName[] = "etw"; | 74 const char kETWTracingAgentNameCopy[] = "etw"; |
| 75 const char kArcTracingAgentName[] = "arc"; | 75 const char kArcTracingAgentNameCopy[] = "arc"; |
| 76 const char kChromeTraceLabel[] = "traceEvents"; | 76 const char kChromeTraceLabel[] = "traceEvents"; |
| 77 | 77 |
| 78 const int kStartTracingTimeoutSeconds = 30; | 78 const int kStartTracingTimeoutSeconds = 30; |
| 79 const int kIssueClockSyncTimeoutSeconds = 30; | 79 const int kIssueClockSyncTimeoutSeconds = 30; |
| 80 const int kStopTracingRetryTimeMilliseconds = 100; | 80 const int kStopTracingRetryTimeMilliseconds = 100; |
| 81 | 81 |
| 82 std::string GetNetworkTypeString() { | 82 std::string GetNetworkTypeString() { |
| 83 switch (net::NetworkChangeNotifier::GetConnectionType()) { | 83 switch (net::NetworkChangeNotifier::GetConnectionType()) { |
| 84 case net::NetworkChangeNotifier::CONNECTION_ETHERNET: | 84 case net::NetworkChangeNotifier::CONNECTION_ETHERNET: |
| 85 return "Ethernet"; | 85 return "Ethernet"; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // Deliberately leaked, like this class. | 139 // Deliberately leaked, like this class. |
| 140 base::FileTracing::SetProvider(new FileTracingProviderImpl); | 140 base::FileTracing::SetProvider(new FileTracingProviderImpl); |
| 141 } | 141 } |
| 142 | 142 |
| 143 TracingControllerImpl::~TracingControllerImpl() { | 143 TracingControllerImpl::~TracingControllerImpl() { |
| 144 // This is a Leaky instance. | 144 // This is a Leaky instance. |
| 145 NOTREACHED(); | 145 NOTREACHED(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 TracingControllerImpl* TracingControllerImpl::GetInstance() { | 148 TracingControllerImpl* TracingControllerImpl::GetInstance() { |
| 149 return g_controller.Pointer(); | 149 return g_tracing_controller.Pointer(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 bool TracingControllerImpl::GetCategories( | 152 bool TracingControllerImpl::GetCategories( |
| 153 const GetCategoriesDoneCallback& callback) { | 153 const GetCategoriesDoneCallback& callback) { |
| 154 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 154 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 155 | 155 |
| 156 // Known categories come back from child processes with the EndTracingAck | 156 // Known categories come back from child processes with the EndTracingAck |
| 157 // message. So to get known categories, just begin and end tracing immediately | 157 // message. So to get known categories, just begin and end tracing immediately |
| 158 // afterwards. This will ping all the child processes for categories. | 158 // afterwards. This will ping all the child processes for categories. |
| 159 pending_get_categories_done_callback_ = callback; | 159 pending_get_categories_done_callback_ = callback; |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 #if defined(OS_CHROMEOS) | 467 #if defined(OS_CHROMEOS) |
| 468 auto* debug_daemon = | 468 auto* debug_daemon = |
| 469 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient(); | 469 chromeos::DBusThreadManager::Get()->GetDebugDaemonClient(); |
| 470 if (agent_name == debug_daemon->GetTracingAgentName()) { | 470 if (agent_name == debug_daemon->GetTracingAgentName()) { |
| 471 additional_tracing_agents_.push_back(debug_daemon); | 471 additional_tracing_agents_.push_back(debug_daemon); |
| 472 debug_daemon->SetStopAgentTracingTaskRunner( | 472 debug_daemon->SetStopAgentTracingTaskRunner( |
| 473 BrowserThread::GetBlockingPool()); | 473 BrowserThread::GetBlockingPool()); |
| 474 return; | 474 return; |
| 475 } | 475 } |
| 476 | 476 |
| 477 if (agent_name == kArcTracingAgentName) { | 477 if (agent_name == kArcTracingAgentNameCopy) { |
| 478 additional_tracing_agents_.push_back(ArcTracingAgent::GetInstance()); | 478 additional_tracing_agents_.push_back(ArcTracingAgent::GetInstance()); |
| 479 return; | 479 return; |
| 480 } | 480 } |
| 481 #elif defined(OS_WIN) | 481 #elif defined(OS_WIN) |
| 482 auto* etw_agent = EtwTracingAgent::GetInstance(); | 482 auto* etw_agent = EtwTracingAgent::GetInstance(); |
| 483 if (agent_name == etw_agent->GetTracingAgentName()) { | 483 if (agent_name == etw_agent->GetTracingAgentName()) { |
| 484 additional_tracing_agents_.push_back(etw_agent); | 484 additional_tracing_agents_.push_back(etw_agent); |
| 485 return; | 485 return; |
| 486 } | 486 } |
| 487 #endif | 487 #endif |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 } | 575 } |
| 576 | 576 |
| 577 void TracingControllerImpl::OnEndAgentTracingAcked( | 577 void TracingControllerImpl::OnEndAgentTracingAcked( |
| 578 const std::string& agent_name, | 578 const std::string& agent_name, |
| 579 const std::string& events_label, | 579 const std::string& events_label, |
| 580 const scoped_refptr<base::RefCountedString>& events_str_ptr) { | 580 const scoped_refptr<base::RefCountedString>& events_str_ptr) { |
| 581 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 581 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 582 | 582 |
| 583 if (trace_data_sink_.get() && events_str_ptr && | 583 if (trace_data_sink_.get() && events_str_ptr && |
| 584 !events_str_ptr->data().empty()) { | 584 !events_str_ptr->data().empty()) { |
| 585 if (agent_name == kETWTracingAgentName) { | 585 if (agent_name == kETWTracingAgentNameCopy) { |
| 586 // The Windows kernel events are kept into a JSON format stored as string | 586 // The Windows kernel events are kept into a JSON format stored as string |
| 587 // and must not be escaped. | 587 // and must not be escaped. |
| 588 trace_data_sink_->AddAgentTrace(events_label, events_str_ptr->data()); | 588 trace_data_sink_->AddAgentTrace(events_label, events_str_ptr->data()); |
| 589 } else if (agent_name == kArcTracingAgentName) { | 589 } else if (agent_name == kArcTracingAgentNameCopy) { |
| 590 // The ARC events are kept into a JSON format stored as string | 590 // The ARC events are kept into a JSON format stored as string |
| 591 // and must not be escaped. | 591 // and must not be escaped. |
| 592 trace_data_sink_->AddTraceChunk(events_str_ptr->data()); | 592 trace_data_sink_->AddTraceChunk(events_str_ptr->data()); |
| 593 } else { | 593 } else { |
| 594 trace_data_sink_->AddAgentTrace( | 594 trace_data_sink_->AddAgentTrace( |
| 595 events_label, base::GetQuotedJSONString(events_str_ptr->data())); | 595 events_label, base::GetQuotedJSONString(events_str_ptr->data())); |
| 596 } | 596 } |
| 597 } | 597 } |
| 598 std::vector<std::string> category_groups; | 598 std::vector<std::string> category_groups; |
| 599 OnStopTracingAcked(NULL, category_groups); | 599 OnStopTracingAcked(NULL, category_groups); |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 base::Time::Now().UTCExplode(&ctime); | 902 base::Time::Now().UTCExplode(&ctime); |
| 903 std::string time_string = base::StringPrintf( | 903 std::string time_string = base::StringPrintf( |
| 904 "%u-%u-%u %d:%d:%d", ctime.year, ctime.month, ctime.day_of_month, | 904 "%u-%u-%u %d:%d:%d", ctime.year, ctime.month, ctime.day_of_month, |
| 905 ctime.hour, ctime.minute, ctime.second); | 905 ctime.hour, ctime.minute, ctime.second); |
| 906 metadata_dict->SetString("trace-capture-datetime", time_string); | 906 metadata_dict->SetString("trace-capture-datetime", time_string); |
| 907 | 907 |
| 908 return metadata_dict; | 908 return metadata_dict; |
| 909 } | 909 } |
| 910 | 910 |
| 911 } // namespace content | 911 } // namespace content |
| OLD | NEW |