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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 typedef base::Callback<void(void)>IOCompleteCallback; | 43 typedef base::Callback<void(void)>IOCompleteCallback; |
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() { |
satorux1
2012/11/05 05:30:37
I'd suggest to leave a comment:
// Don't close pi
| |
54 if (pipe_fd_[0] != -1) | |
55 if (HANDLE_EINTR(close(pipe_fd_[0])) < 0) | |
56 PLOG(ERROR) << "close[0]"; | |
57 if (pipe_fd_[1] != -1) | 54 if (pipe_fd_[1] != -1) |
58 if (HANDLE_EINTR(close(pipe_fd_[1])) < 0) | 55 if (HANDLE_EINTR(close(pipe_fd_[1])) < 0) |
59 PLOG(ERROR) << "close[1]"; | 56 PLOG(ERROR) << "close[1]"; |
60 } | 57 } |
61 | 58 |
62 // Returns descriptor for the writeable side of the pipe. | 59 // Returns descriptor for the writeable side of the pipe. |
63 int GetWriteFD() { return pipe_fd_[1]; } | 60 int GetWriteFD() { return pipe_fd_[1]; } |
64 | 61 |
65 // Closes writeable descriptor; normally used in parent process after fork. | 62 // Closes writeable descriptor; normally used in parent process after fork. |
66 void CloseWriteFD() { | 63 void CloseWriteFD() { |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
562 // static | 559 // static |
563 DebugDaemonClient* DebugDaemonClient::Create(DBusClientImplementationType type, | 560 DebugDaemonClient* DebugDaemonClient::Create(DBusClientImplementationType type, |
564 dbus::Bus* bus) { | 561 dbus::Bus* bus) { |
565 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 562 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
566 return new DebugDaemonClientImpl(bus); | 563 return new DebugDaemonClientImpl(bus); |
567 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 564 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
568 return new DebugDaemonClientStubImpl(); | 565 return new DebugDaemonClientStubImpl(); |
569 } | 566 } |
570 | 567 |
571 } // namespace chromeos | 568 } // namespace chromeos |
OLD | NEW |