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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 // static | 504 // static |
505 DebugDaemonClient* DebugDaemonClient::Create(DBusClientImplementationType type, | 505 DebugDaemonClient* DebugDaemonClient::Create(DBusClientImplementationType type, |
506 dbus::Bus* bus) { | 506 dbus::Bus* bus) { |
507 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 507 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
508 return new DebugDaemonClientImpl(bus); | 508 return new DebugDaemonClientImpl(bus); |
509 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 509 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
510 return new DebugDaemonClientStubImpl(); | 510 return new DebugDaemonClientStubImpl(); |
511 } | 511 } |
512 | 512 |
513 } // namespace chromeos | 513 } // namespace chromeos |
OLD | NEW |