| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 weak_ptr_factory_(this), | 48 weak_ptr_factory_(this), |
| 49 callback_(callback) { | 49 callback_(callback) { |
| 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 if (pipe_fd_[0] != -1) |
| 55 if (HANDLE_EINTR(close(pipe_fd_[0])) < 0) | 55 if (!data_stream_.get() && HANDLE_EINTR(close(pipe_fd_[0])) < 0) |
| 56 PLOG(ERROR) << "close[0]"; | 56 PLOG(ERROR) << "close[0]"; |
| 57 if (pipe_fd_[1] != -1) | 57 if (pipe_fd_[1] != -1) |
| 58 if (HANDLE_EINTR(close(pipe_fd_[1])) < 0) | 58 if (HANDLE_EINTR(close(pipe_fd_[1])) < 0) |
| 59 PLOG(ERROR) << "close[1]"; | 59 PLOG(ERROR) << "close[1]"; |
| 60 } | 60 } |
| 61 | 61 |
| 62 // Returns descriptor for the writeable side of the pipe. | 62 // Returns descriptor for the writeable side of the pipe. |
| 63 int GetWriteFD() { return pipe_fd_[1]; } | 63 int GetWriteFD() { return pipe_fd_[1]; } |
| 64 | 64 |
| 65 // Closes writeable descriptor; normally used in parent process after fork. | 65 // Closes writeable descriptor; normally used in parent process after fork. |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 // static | 529 // static |
| 530 DebugDaemonClient* DebugDaemonClient::Create(DBusClientImplementationType type, | 530 DebugDaemonClient* DebugDaemonClient::Create(DBusClientImplementationType type, |
| 531 dbus::Bus* bus) { | 531 dbus::Bus* bus) { |
| 532 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 532 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 533 return new DebugDaemonClientImpl(bus); | 533 return new DebugDaemonClientImpl(bus); |
| 534 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 534 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 535 return new DebugDaemonClientStubImpl(); | 535 return new DebugDaemonClientStubImpl(); |
| 536 } | 536 } |
| 537 | 537 |
| 538 } // namespace chromeos | 538 } // namespace chromeos |
| OLD | NEW |