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 : io_buffer_(new net::IOBufferWithSize(4096)), | 46 : io_buffer_(new net::IOBufferWithSize(4096)), |
47 callback_(callback), | 47 callback_(callback), |
48 weak_ptr_factory_(this) { | 48 weak_ptr_factory_(this) { |
49 pipe_fd_[0] = pipe_fd_[1] = -1; | 49 pipe_fd_[0] = pipe_fd_[1] = -1; |
50 } | 50 } |
51 | 51 |
52 virtual ~PipeReader() { | 52 virtual ~PipeReader() { |
53 // Don't close pipe_fd_[0] as it's closed by data_stream_. | 53 // Don't close pipe_fd_[0] as it's closed by data_stream_. |
54 if (pipe_fd_[1] != -1) | 54 if (pipe_fd_[1] != -1) |
55 if (HANDLE_EINTR(close(pipe_fd_[1])) < 0) | 55 if (IGNORE_EINTR(close(pipe_fd_[1])) < 0) |
56 PLOG(ERROR) << "close[1]"; | 56 PLOG(ERROR) << "close[1]"; |
57 } | 57 } |
58 | 58 |
59 // Returns descriptor for the writeable side of the pipe. | 59 // Returns descriptor for the writeable side of the pipe. |
60 int GetWriteFD() { return pipe_fd_[1]; } | 60 int GetWriteFD() { return pipe_fd_[1]; } |
61 | 61 |
62 // Closes writeable descriptor; normally used in parent process after fork. | 62 // Closes writeable descriptor; normally used in parent process after fork. |
63 void CloseWriteFD() { | 63 void CloseWriteFD() { |
64 if (pipe_fd_[1] != -1) { | 64 if (pipe_fd_[1] != -1) { |
65 if (HANDLE_EINTR(close(pipe_fd_[1])) < 0) | 65 if (IGNORE_EINTR(close(pipe_fd_[1])) < 0) |
66 PLOG(ERROR) << "close"; | 66 PLOG(ERROR) << "close"; |
67 pipe_fd_[1] = -1; | 67 pipe_fd_[1] = -1; |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 // Returns collected data. | 71 // Returns collected data. |
72 std::string* data() { return &data_; } | 72 std::string* data() { return &data_; } |
73 | 73 |
74 // Starts data collection. Returns true if stream was setup correctly. | 74 // Starts data collection. Returns true if stream was setup correctly. |
75 // On success data will automatically be accumulated into a string that | 75 // On success data will automatically be accumulated into a string that |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 // static | 719 // static |
720 DebugDaemonClient* DebugDaemonClient::Create( | 720 DebugDaemonClient* DebugDaemonClient::Create( |
721 DBusClientImplementationType type) { | 721 DBusClientImplementationType type) { |
722 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 722 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
723 return new DebugDaemonClientImpl(); | 723 return new DebugDaemonClientImpl(); |
724 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 724 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
725 return new DebugDaemonClientStubImpl(); | 725 return new DebugDaemonClientStubImpl(); |
726 } | 726 } |
727 | 727 |
728 } // namespace chromeos | 728 } // namespace chromeos |
OLD | NEW |