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 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()) |
| 56 data_stream_->CloseAndCancelAsync(); |
| 57 else if (HANDLE_EINTR(close(pipe_fd_[0])) < 0) |
56 PLOG(ERROR) << "close[0]"; | 58 PLOG(ERROR) << "close[0]"; |
| 59 } |
57 if (pipe_fd_[1] != -1) | 60 if (pipe_fd_[1] != -1) |
58 if (HANDLE_EINTR(close(pipe_fd_[1])) < 0) | 61 if (HANDLE_EINTR(close(pipe_fd_[1])) < 0) |
59 PLOG(ERROR) << "close[1]"; | 62 PLOG(ERROR) << "close[1]"; |
60 } | 63 } |
61 | 64 |
62 // Returns descriptor for the writeable side of the pipe. | 65 // Returns descriptor for the writeable side of the pipe. |
63 int GetWriteFD() { return pipe_fd_[1]; } | 66 int GetWriteFD() { return pipe_fd_[1]; } |
64 | 67 |
65 // Closes writeable descriptor; normally used in parent process after fork. | 68 // Closes writeable descriptor; normally used in parent process after fork. |
66 void CloseWriteFD() { | 69 void CloseWriteFD() { |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 // static | 507 // static |
505 DebugDaemonClient* DebugDaemonClient::Create(DBusClientImplementationType type, | 508 DebugDaemonClient* DebugDaemonClient::Create(DBusClientImplementationType type, |
506 dbus::Bus* bus) { | 509 dbus::Bus* bus) { |
507 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 510 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
508 return new DebugDaemonClientImpl(bus); | 511 return new DebugDaemonClientImpl(bus); |
509 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 512 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
510 return new DebugDaemonClientStubImpl(); | 513 return new DebugDaemonClientStubImpl(); |
511 } | 514 } |
512 | 515 |
513 } // namespace chromeos | 516 } // namespace chromeos |
OLD | NEW |