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 <unistd.h> | 8 #include <unistd.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 28 matching lines...) Expand all Loading... |
39 namespace chromeos { | 39 namespace chromeos { |
40 | 40 |
41 // The DebugDaemonClient implementation used in production. | 41 // The DebugDaemonClient implementation used in production. |
42 class DebugDaemonClientImpl : public DebugDaemonClient { | 42 class DebugDaemonClientImpl : public DebugDaemonClient { |
43 public: | 43 public: |
44 DebugDaemonClientImpl() : debugdaemon_proxy_(NULL), weak_ptr_factory_(this) {} | 44 DebugDaemonClientImpl() : debugdaemon_proxy_(NULL), weak_ptr_factory_(this) {} |
45 | 45 |
46 virtual ~DebugDaemonClientImpl() {} | 46 virtual ~DebugDaemonClientImpl() {} |
47 | 47 |
48 // DebugDaemonClient override. | 48 // DebugDaemonClient override. |
49 virtual void GetDebugLogs(base::File file, | 49 virtual void DumpDebugLogs(bool is_compressed, |
50 const GetDebugLogsCallback& callback) OVERRIDE { | 50 base::File file, |
51 | 51 const GetDebugLogsCallback& callback) OVERRIDE { |
52 dbus::FileDescriptor* file_descriptor = new dbus::FileDescriptor; | 52 dbus::FileDescriptor* file_descriptor = new dbus::FileDescriptor; |
53 file_descriptor->PutValue(file.TakePlatformFile()); | 53 file_descriptor->PutValue(file.TakePlatformFile()); |
54 // Punt descriptor validity check to a worker thread; on return we'll | 54 // Punt descriptor validity check to a worker thread; on return we'll |
55 // issue the D-Bus request to stop tracing and collect results. | 55 // issue the D-Bus request to stop tracing and collect results. |
56 base::WorkerPool::PostTaskAndReply( | 56 base::WorkerPool::PostTaskAndReply( |
57 FROM_HERE, | 57 FROM_HERE, |
58 base::Bind(&dbus::FileDescriptor::CheckValidity, | 58 base::Bind(&dbus::FileDescriptor::CheckValidity, |
59 base::Unretained(file_descriptor)), | 59 base::Unretained(file_descriptor)), |
60 base::Bind(&DebugDaemonClientImpl::OnCheckValidityGetDebugLogs, | 60 base::Bind(&DebugDaemonClientImpl::OnCheckValidityGetDebugLogs, |
61 weak_ptr_factory_.GetWeakPtr(), | 61 weak_ptr_factory_.GetWeakPtr(), |
| 62 is_compressed, |
62 base::Owned(file_descriptor), | 63 base::Owned(file_descriptor), |
63 callback), | 64 callback), |
64 false); | 65 false); |
65 } | 66 } |
66 | 67 |
67 virtual void SetDebugMode(const std::string& subsystem, | 68 virtual void SetDebugMode(const std::string& subsystem, |
68 const SetDebugModeCallback& callback) OVERRIDE { | 69 const SetDebugModeCallback& callback) OVERRIDE { |
69 dbus::MethodCall method_call(debugd::kDebugdInterface, | 70 dbus::MethodCall method_call(debugd::kDebugdInterface, |
70 debugd::kSetDebugMode); | 71 debugd::kSetDebugMode); |
71 dbus::MessageWriter writer(&method_call); | 72 dbus::MessageWriter writer(&method_call); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 | 307 |
307 protected: | 308 protected: |
308 virtual void Init(dbus::Bus* bus) OVERRIDE { | 309 virtual void Init(dbus::Bus* bus) OVERRIDE { |
309 debugdaemon_proxy_ = | 310 debugdaemon_proxy_ = |
310 bus->GetObjectProxy(debugd::kDebugdServiceName, | 311 bus->GetObjectProxy(debugd::kDebugdServiceName, |
311 dbus::ObjectPath(debugd::kDebugdServicePath)); | 312 dbus::ObjectPath(debugd::kDebugdServicePath)); |
312 } | 313 } |
313 | 314 |
314 private: | 315 private: |
315 // Called when a CheckValidity response is received. | 316 // Called when a CheckValidity response is received. |
316 void OnCheckValidityGetDebugLogs(dbus::FileDescriptor* file_descriptor, | 317 void OnCheckValidityGetDebugLogs(bool is_compressed, |
| 318 dbus::FileDescriptor* file_descriptor, |
317 const GetDebugLogsCallback& callback) { | 319 const GetDebugLogsCallback& callback) { |
318 // Issue the dbus request to get debug logs. | 320 // Issue the dbus request to get debug logs. |
319 dbus::MethodCall method_call( | 321 dbus::MethodCall method_call(debugd::kDebugdInterface, |
320 debugd::kDebugdInterface, | 322 debugd::kDumpDebugLogs); |
321 debugd::kGetDebugLogs); | |
322 dbus::MessageWriter writer(&method_call); | 323 dbus::MessageWriter writer(&method_call); |
| 324 writer.AppendBool(is_compressed); |
323 writer.AppendFileDescriptor(*file_descriptor); | 325 writer.AppendFileDescriptor(*file_descriptor); |
324 | 326 |
325 debugdaemon_proxy_->CallMethod( | 327 debugdaemon_proxy_->CallMethod( |
326 &method_call, | 328 &method_call, |
327 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 329 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
328 base::Bind(&DebugDaemonClientImpl::OnGetDebugLogs, | 330 base::Bind(&DebugDaemonClientImpl::OnGetDebugLogs, |
329 weak_ptr_factory_.GetWeakPtr(), | 331 weak_ptr_factory_.GetWeakPtr(), |
330 callback)); | 332 callback)); |
331 } | 333 } |
332 | 334 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 DebugDaemonClient::EmptyStopSystemTracingCallback() { | 548 DebugDaemonClient::EmptyStopSystemTracingCallback() { |
547 return base::Bind(&EmptyStopSystemTracingCallbackBody); | 549 return base::Bind(&EmptyStopSystemTracingCallbackBody); |
548 } | 550 } |
549 | 551 |
550 // static | 552 // static |
551 DebugDaemonClient* DebugDaemonClient::Create() { | 553 DebugDaemonClient* DebugDaemonClient::Create() { |
552 return new DebugDaemonClientImpl(); | 554 return new DebugDaemonClientImpl(); |
553 } | 555 } |
554 | 556 |
555 } // namespace chromeos | 557 } // namespace chromeos |
OLD | NEW |