OLD | NEW |
---|---|
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 "chromeos/dbus/debug_daemon_client.h" | 5 #include "chromeos/dbus/debug_daemon_client.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
17 #include "base/location.h" | 17 #include "base/location.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
20 #include "base/posix/eintr_wrapper.h" | 20 #include "base/posix/eintr_wrapper.h" |
21 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
22 #include "base/task_runner_util.h" | 22 #include "base/task_runner_util.h" |
23 #include "base/thread_task_runner_handle.h" | |
23 #include "chromeos/dbus/pipe_reader.h" | 24 #include "chromeos/dbus/pipe_reader.h" |
24 #include "dbus/bus.h" | 25 #include "dbus/bus.h" |
25 #include "dbus/message.h" | 26 #include "dbus/message.h" |
26 #include "dbus/object_path.h" | 27 #include "dbus/object_path.h" |
27 #include "dbus/object_proxy.h" | 28 #include "dbus/object_proxy.h" |
28 | 29 |
29 namespace { | 30 namespace { |
30 | 31 |
31 const char kCrOSTracingAgentName[] = "cros"; | 32 const char kCrOSTracingAgentName[] = "cros"; |
32 const char kCrOSTraceLabel[] = "systemTraceEvents"; | 33 const char kCrOSTraceLabel[] = "systemTraceEvents"; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 base::Bind(&DebugDaemonClientImpl::OnGetUserLogFiles, | 200 base::Bind(&DebugDaemonClientImpl::OnGetUserLogFiles, |
200 weak_ptr_factory_.GetWeakPtr(), | 201 weak_ptr_factory_.GetWeakPtr(), |
201 callback)); | 202 callback)); |
202 } | 203 } |
203 | 204 |
204 // base::trace_event::TracingAgent implementation. | 205 // base::trace_event::TracingAgent implementation. |
205 std::string GetTracingAgentName() override { return kCrOSTracingAgentName; } | 206 std::string GetTracingAgentName() override { return kCrOSTracingAgentName; } |
206 | 207 |
207 std::string GetTraceEventLabel() override { return kCrOSTraceLabel; } | 208 std::string GetTraceEventLabel() override { return kCrOSTraceLabel; } |
208 | 209 |
209 bool StartAgentTracing( | 210 void StartAgentTracing(const base::trace_event::TraceConfig& trace_config, |
210 const base::trace_event::TraceConfig& trace_config) override { | 211 const StartAgentTracingCallback& callback) override { |
211 dbus::MethodCall method_call( | 212 dbus::MethodCall method_call( |
212 debugd::kDebugdInterface, | 213 debugd::kDebugdInterface, |
213 debugd::kSystraceStart); | 214 debugd::kSystraceStart); |
214 dbus::MessageWriter writer(&method_call); | 215 dbus::MessageWriter writer(&method_call); |
215 writer.AppendString("all"); // TODO(sleffler) parameterize category list | 216 writer.AppendString("all"); // TODO(sleffler) parameterize category list |
216 | 217 |
217 DVLOG(1) << "Requesting a systrace start"; | 218 DVLOG(1) << "Requesting a systrace start"; |
218 debugdaemon_proxy_->CallMethod( | 219 debugdaemon_proxy_->CallMethod( |
219 &method_call, | 220 &method_call, |
220 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 221 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
221 base::Bind(&DebugDaemonClientImpl::OnStartMethod, | 222 base::Bind(&DebugDaemonClientImpl::OnStartMethod, |
222 weak_ptr_factory_.GetWeakPtr())); | 223 weak_ptr_factory_.GetWeakPtr())); |
223 return true; | 224 |
225 base::ThreadTaskRunnerHandle::Get()->PostTask( | |
226 FROM_HERE, base::Bind(callback, GetTracingAgentName(), true)); | |
stevenjb
2016/01/26 20:11:19
Document |success|, i.e: true /* success */
charliea (OOO until 10-5)
2016/01/26 20:29:56
Ah, didn't know that you were supposed to do this.
| |
224 } | 227 } |
225 | 228 |
226 void StopAgentTracing(const StopAgentTracingCallback& callback) override { | 229 void StopAgentTracing(const StopAgentTracingCallback& callback) override { |
227 DCHECK(stop_agent_tracing_task_runner_); | 230 DCHECK(stop_agent_tracing_task_runner_); |
228 if (pipe_reader_ != NULL) { | 231 if (pipe_reader_ != NULL) { |
229 LOG(ERROR) << "Busy doing StopSystemTracing"; | 232 LOG(ERROR) << "Busy doing StopSystemTracing"; |
230 return; | 233 return; |
231 } | 234 } |
232 | 235 |
233 pipe_reader_.reset( | 236 pipe_reader_.reset( |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
641 DebugDaemonClient::EmptyStopAgentTracingCallback() { | 644 DebugDaemonClient::EmptyStopAgentTracingCallback() { |
642 return base::Bind(&EmptyStopAgentTracingCallbackBody); | 645 return base::Bind(&EmptyStopAgentTracingCallbackBody); |
643 } | 646 } |
644 | 647 |
645 // static | 648 // static |
646 DebugDaemonClient* DebugDaemonClient::Create() { | 649 DebugDaemonClient* DebugDaemonClient::Create() { |
647 return new DebugDaemonClientImpl(); | 650 return new DebugDaemonClientImpl(); |
648 } | 651 } |
649 | 652 |
650 } // namespace chromeos | 653 } // namespace chromeos |
OLD | NEW |