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, |
| 227 base::Bind(callback, GetTracingAgentName(), true /* success */)); |
224 } | 228 } |
225 | 229 |
226 void StopAgentTracing(const StopAgentTracingCallback& callback) override { | 230 void StopAgentTracing(const StopAgentTracingCallback& callback) override { |
227 DCHECK(stop_agent_tracing_task_runner_); | 231 DCHECK(stop_agent_tracing_task_runner_); |
228 if (pipe_reader_ != NULL) { | 232 if (pipe_reader_ != NULL) { |
229 LOG(ERROR) << "Busy doing StopSystemTracing"; | 233 LOG(ERROR) << "Busy doing StopSystemTracing"; |
230 return; | 234 return; |
231 } | 235 } |
232 | 236 |
233 pipe_reader_.reset( | 237 pipe_reader_.reset( |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 DebugDaemonClient::EmptyStopAgentTracingCallback() { | 645 DebugDaemonClient::EmptyStopAgentTracingCallback() { |
642 return base::Bind(&EmptyStopAgentTracingCallbackBody); | 646 return base::Bind(&EmptyStopAgentTracingCallbackBody); |
643 } | 647 } |
644 | 648 |
645 // static | 649 // static |
646 DebugDaemonClient* DebugDaemonClient::Create() { | 650 DebugDaemonClient* DebugDaemonClient::Create() { |
647 return new DebugDaemonClientImpl(); | 651 return new DebugDaemonClientImpl(); |
648 } | 652 } |
649 | 653 |
650 } // namespace chromeos | 654 } // namespace chromeos |
OLD | NEW |