| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 explicit PipeReader(IOCompleteCallback callback) | 45 explicit PipeReader(IOCompleteCallback callback) |
| 46 : data_stream_(NULL), | 46 : data_stream_(NULL), |
| 47 io_buffer_(new net::IOBufferWithSize(4096)), | 47 io_buffer_(new net::IOBufferWithSize(4096)), |
| 48 callback_(callback), | 48 callback_(callback), |
| 49 weak_ptr_factory_(this) { | 49 weak_ptr_factory_(this) { |
| 50 pipe_fd_[0] = pipe_fd_[1] = -1; | 50 pipe_fd_[0] = pipe_fd_[1] = -1; |
| 51 } | 51 } |
| 52 | 52 |
| 53 virtual ~PipeReader() { | 53 virtual ~PipeReader() { |
| 54 if (pipe_fd_[0] != -1) | 54 // Don't close pipe_fd_[0] as it's closed by data_stream_. |
| 55 if (HANDLE_EINTR(close(pipe_fd_[0])) < 0) | |
| 56 PLOG(ERROR) << "close[0]"; | |
| 57 if (pipe_fd_[1] != -1) | 55 if (pipe_fd_[1] != -1) |
| 58 if (HANDLE_EINTR(close(pipe_fd_[1])) < 0) | 56 if (HANDLE_EINTR(close(pipe_fd_[1])) < 0) |
| 59 PLOG(ERROR) << "close[1]"; | 57 PLOG(ERROR) << "close[1]"; |
| 60 } | 58 } |
| 61 | 59 |
| 62 // Returns descriptor for the writeable side of the pipe. | 60 // Returns descriptor for the writeable side of the pipe. |
| 63 int GetWriteFD() { return pipe_fd_[1]; } | 61 int GetWriteFD() { return pipe_fd_[1]; } |
| 64 | 62 |
| 65 // Closes writeable descriptor; normally used in parent process after fork. | 63 // Closes writeable descriptor; normally used in parent process after fork. |
| 66 void CloseWriteFD() { | 64 void CloseWriteFD() { |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 // static | 560 // static |
| 563 DebugDaemonClient* DebugDaemonClient::Create(DBusClientImplementationType type, | 561 DebugDaemonClient* DebugDaemonClient::Create(DBusClientImplementationType type, |
| 564 dbus::Bus* bus) { | 562 dbus::Bus* bus) { |
| 565 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 563 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 566 return new DebugDaemonClientImpl(bus); | 564 return new DebugDaemonClientImpl(bus); |
| 567 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 565 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 568 return new DebugDaemonClientStubImpl(); | 566 return new DebugDaemonClientStubImpl(); |
| 569 } | 567 } |
| 570 | 568 |
| 571 } // namespace chromeos | 569 } // namespace chromeos |
| OLD | NEW |