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 <fcntl.h> | 5 #include <fcntl.h> |
6 #include <unistd.h> | 6 #include <unistd.h> |
7 | 7 |
8 #include "chromeos/dbus/debug_daemon_client.h" | 8 #include "chromeos/dbus/debug_daemon_client.h" |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 // the instance on callback. The data should be retrieved before | 37 // the instance on callback. The data should be retrieved before |
38 // delete and extracted or copied. | 38 // delete and extracted or copied. |
39 // | 39 // |
40 // TODO(sleffler) move data collection to a sub-class so this | 40 // TODO(sleffler) move data collection to a sub-class so this |
41 // can be reused to process data as it is received | 41 // can be reused to process data as it is received |
42 class PipeReader { | 42 class PipeReader { |
43 public: | 43 public: |
44 typedef base::Callback<void(void)>IOCompleteCallback; | 44 typedef base::Callback<void(void)>IOCompleteCallback; |
45 | 45 |
46 explicit PipeReader(IOCompleteCallback callback) | 46 explicit PipeReader(IOCompleteCallback callback) |
47 : data_stream_(NULL), | 47 : io_buffer_(new net::IOBufferWithSize(4096)), |
48 io_buffer_(new net::IOBufferWithSize(4096)), | |
49 callback_(callback), | 48 callback_(callback), |
50 weak_ptr_factory_(this) { | 49 weak_ptr_factory_(this) { |
51 pipe_fd_[0] = pipe_fd_[1] = -1; | 50 pipe_fd_[0] = pipe_fd_[1] = -1; |
52 } | 51 } |
53 | 52 |
54 virtual ~PipeReader() { | 53 virtual ~PipeReader() { |
55 // Don't close pipe_fd_[0] as it's closed by data_stream_. | 54 // Don't close pipe_fd_[0] as it's closed by data_stream_. |
56 if (pipe_fd_[1] != -1) | 55 if (pipe_fd_[1] != -1) |
57 if (HANDLE_EINTR(close(pipe_fd_[1])) < 0) | 56 if (HANDLE_EINTR(close(pipe_fd_[1])) < 0) |
58 PLOG(ERROR) << "close[1]"; | 57 PLOG(ERROR) << "close[1]"; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 135 |
137 } // namespace | 136 } // namespace |
138 | 137 |
139 namespace chromeos { | 138 namespace chromeos { |
140 | 139 |
141 // The DebugDaemonClient implementation used in production. | 140 // The DebugDaemonClient implementation used in production. |
142 class DebugDaemonClientImpl : public DebugDaemonClient { | 141 class DebugDaemonClientImpl : public DebugDaemonClient { |
143 public: | 142 public: |
144 explicit DebugDaemonClientImpl(dbus::Bus* bus) | 143 explicit DebugDaemonClientImpl(dbus::Bus* bus) |
145 : debugdaemon_proxy_(NULL), | 144 : debugdaemon_proxy_(NULL), |
146 pipe_reader_(NULL), | |
147 weak_ptr_factory_(this) { | 145 weak_ptr_factory_(this) { |
148 debugdaemon_proxy_ = bus->GetObjectProxy( | 146 debugdaemon_proxy_ = bus->GetObjectProxy( |
149 debugd::kDebugdServiceName, | 147 debugd::kDebugdServiceName, |
150 dbus::ObjectPath(debugd::kDebugdServicePath)); | 148 dbus::ObjectPath(debugd::kDebugdServicePath)); |
151 } | 149 } |
152 | 150 |
153 virtual ~DebugDaemonClientImpl() {} | 151 virtual ~DebugDaemonClientImpl() {} |
154 | 152 |
155 // DebugDaemonClient override. | 153 // DebugDaemonClient override. |
156 virtual void GetDebugLogs(base::PlatformFile file, | 154 virtual void GetDebugLogs(base::PlatformFile file, |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 // static | 632 // static |
635 DebugDaemonClient* DebugDaemonClient::Create(DBusClientImplementationType type, | 633 DebugDaemonClient* DebugDaemonClient::Create(DBusClientImplementationType type, |
636 dbus::Bus* bus) { | 634 dbus::Bus* bus) { |
637 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 635 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
638 return new DebugDaemonClientImpl(bus); | 636 return new DebugDaemonClientImpl(bus); |
639 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 637 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
640 return new DebugDaemonClientStubImpl(); | 638 return new DebugDaemonClientStubImpl(); |
641 } | 639 } |
642 | 640 |
643 } // namespace chromeos | 641 } // namespace chromeos |
OLD | NEW |