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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 }; | 134 }; |
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), weak_ptr_factory_(this) { |
Daniel Erat
2013/06/13 15:46:33
nit: i believe that these should remain on separat
dcheng
2013/06/13 15:48:11
This is the result from clang-format-diff. If you
Daniel Erat
2013/06/13 15:49:44
thanks, please do so. i think that clang-format-di
dcheng
2013/06/13 18:49:20
Done.
However, a literal reading suggests that th
| |
146 pipe_reader_(NULL), | |
147 weak_ptr_factory_(this) { | |
148 debugdaemon_proxy_ = bus->GetObjectProxy( | 145 debugdaemon_proxy_ = bus->GetObjectProxy( |
149 debugd::kDebugdServiceName, | 146 debugd::kDebugdServiceName, |
150 dbus::ObjectPath(debugd::kDebugdServicePath)); | 147 dbus::ObjectPath(debugd::kDebugdServicePath)); |
151 } | 148 } |
152 | 149 |
153 virtual ~DebugDaemonClientImpl() {} | 150 virtual ~DebugDaemonClientImpl() {} |
154 | 151 |
155 // DebugDaemonClient override. | 152 // DebugDaemonClient override. |
156 virtual void GetDebugLogs(base::PlatformFile file, | 153 virtual void GetDebugLogs(base::PlatformFile file, |
157 const GetDebugLogsCallback& callback) OVERRIDE { | 154 const GetDebugLogsCallback& callback) OVERRIDE { |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
634 // static | 631 // static |
635 DebugDaemonClient* DebugDaemonClient::Create(DBusClientImplementationType type, | 632 DebugDaemonClient* DebugDaemonClient::Create(DBusClientImplementationType type, |
636 dbus::Bus* bus) { | 633 dbus::Bus* bus) { |
637 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 634 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
638 return new DebugDaemonClientImpl(bus); | 635 return new DebugDaemonClientImpl(bus); |
639 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 636 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
640 return new DebugDaemonClientStubImpl(); | 637 return new DebugDaemonClientStubImpl(); |
641 } | 638 } |
642 | 639 |
643 } // namespace chromeos | 640 } // namespace chromeos |
OLD | NEW |