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> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/files/file_path.h" |
15 #include "base/location.h" | 16 #include "base/location.h" |
16 #include "base/memory/ref_counted_memory.h" | 17 #include "base/memory/ref_counted_memory.h" |
17 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
18 #include "base/platform_file.h" | |
19 #include "base/posix/eintr_wrapper.h" | 19 #include "base/posix/eintr_wrapper.h" |
20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
21 #include "base/task_runner_util.h" | 21 #include "base/task_runner_util.h" |
22 #include "base/threading/worker_pool.h" | 22 #include "base/threading/worker_pool.h" |
23 #include "chromeos/dbus/pipe_reader.h" | 23 #include "chromeos/dbus/pipe_reader.h" |
24 #include "dbus/bus.h" | 24 #include "dbus/bus.h" |
25 #include "dbus/message.h" | 25 #include "dbus/message.h" |
26 #include "dbus/object_path.h" | 26 #include "dbus/object_path.h" |
27 #include "dbus/object_proxy.h" | 27 #include "dbus/object_proxy.h" |
28 #include "third_party/cros_system_api/dbus/service_constants.h" | 28 #include "third_party/cros_system_api/dbus/service_constants.h" |
(...skipping 10 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::PlatformFile file, | 49 virtual void GetDebugLogs(base::File file, |
50 const GetDebugLogsCallback& callback) OVERRIDE { | 50 const GetDebugLogsCallback& callback) OVERRIDE { |
51 | 51 |
52 dbus::FileDescriptor* file_descriptor = new dbus::FileDescriptor(file); | 52 dbus::FileDescriptor* file_descriptor = new dbus::FileDescriptor; |
| 53 file_descriptor->PutValue(file.TakePlatformFile()); |
53 // 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 |
54 // issue the D-Bus request to stop tracing and collect results. | 55 // issue the D-Bus request to stop tracing and collect results. |
55 base::WorkerPool::PostTaskAndReply( | 56 base::WorkerPool::PostTaskAndReply( |
56 FROM_HERE, | 57 FROM_HERE, |
57 base::Bind(&dbus::FileDescriptor::CheckValidity, | 58 base::Bind(&dbus::FileDescriptor::CheckValidity, |
58 base::Unretained(file_descriptor)), | 59 base::Unretained(file_descriptor)), |
59 base::Bind(&DebugDaemonClientImpl::OnCheckValidityGetDebugLogs, | 60 base::Bind(&DebugDaemonClientImpl::OnCheckValidityGetDebugLogs, |
60 weak_ptr_factory_.GetWeakPtr(), | 61 weak_ptr_factory_.GetWeakPtr(), |
61 base::Owned(file_descriptor), | 62 base::Owned(file_descriptor), |
62 callback), | 63 callback), |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 DebugDaemonClient::EmptyStopSystemTracingCallback() { | 546 DebugDaemonClient::EmptyStopSystemTracingCallback() { |
546 return base::Bind(&EmptyStopSystemTracingCallbackBody); | 547 return base::Bind(&EmptyStopSystemTracingCallbackBody); |
547 } | 548 } |
548 | 549 |
549 // static | 550 // static |
550 DebugDaemonClient* DebugDaemonClient::Create() { | 551 DebugDaemonClient* DebugDaemonClient::Create() { |
551 return new DebugDaemonClientImpl(); | 552 return new DebugDaemonClientImpl(); |
552 } | 553 } |
553 | 554 |
554 } // namespace chromeos | 555 } // namespace chromeos |
OLD | NEW |