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