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 "chromeos/dbus/debug_daemon_client.h" | 5 #include "chromeos/dbus/debug_daemon_client.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <unistd.h> | 8 #include <unistd.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 explicit PipeReader(IOCompleteCallback callback) | 49 explicit PipeReader(IOCompleteCallback callback) |
50 : io_buffer_(new net::IOBufferWithSize(4096)), | 50 : io_buffer_(new net::IOBufferWithSize(4096)), |
51 callback_(callback), | 51 callback_(callback), |
52 weak_ptr_factory_(this) { | 52 weak_ptr_factory_(this) { |
53 pipe_fd_[0] = pipe_fd_[1] = -1; | 53 pipe_fd_[0] = pipe_fd_[1] = -1; |
54 } | 54 } |
55 | 55 |
56 virtual ~PipeReader() { | 56 virtual ~PipeReader() { |
57 // Don't close pipe_fd_[0] as it's closed by data_stream_. | 57 // Don't close pipe_fd_[0] as it's closed by data_stream_. |
58 if (pipe_fd_[1] != -1) | 58 if (pipe_fd_[1] != -1) |
59 if (HANDLE_EINTR(close(pipe_fd_[1])) < 0) | 59 if (IGNORE_EINTR(close(pipe_fd_[1])) < 0) |
60 PLOG(ERROR) << "close[1]"; | 60 PLOG(ERROR) << "close[1]"; |
61 } | 61 } |
62 | 62 |
63 // Returns descriptor for the writeable side of the pipe. | 63 // Returns descriptor for the writeable side of the pipe. |
64 int GetWriteFD() { return pipe_fd_[1]; } | 64 int GetWriteFD() { return pipe_fd_[1]; } |
65 | 65 |
66 // Closes writeable descriptor; normally used in parent process after fork. | 66 // Closes writeable descriptor; normally used in parent process after fork. |
67 void CloseWriteFD() { | 67 void CloseWriteFD() { |
68 if (pipe_fd_[1] != -1) { | 68 if (pipe_fd_[1] != -1) { |
69 if (HANDLE_EINTR(close(pipe_fd_[1])) < 0) | 69 if (IGNORE_EINTR(close(pipe_fd_[1])) < 0) |
70 PLOG(ERROR) << "close"; | 70 PLOG(ERROR) << "close"; |
71 pipe_fd_[1] = -1; | 71 pipe_fd_[1] = -1; |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 // Returns collected data. | 75 // Returns collected data. |
76 std::string* data() { return &data_; } | 76 std::string* data() { return &data_; } |
77 | 77 |
78 // Starts data collection. Returns true if stream was setup correctly. | 78 // Starts data collection. Returns true if stream was setup correctly. |
79 // On success data will automatically be accumulated into a string that | 79 // On success data will automatically be accumulated into a string that |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 DebugDaemonClient::EmptyStopSystemTracingCallback() { | 631 DebugDaemonClient::EmptyStopSystemTracingCallback() { |
632 return base::Bind(&EmptyStopSystemTracingCallbackBody); | 632 return base::Bind(&EmptyStopSystemTracingCallbackBody); |
633 } | 633 } |
634 | 634 |
635 // static | 635 // static |
636 DebugDaemonClient* DebugDaemonClient::Create() { | 636 DebugDaemonClient* DebugDaemonClient::Create() { |
637 return new DebugDaemonClientImpl(); | 637 return new DebugDaemonClientImpl(); |
638 } | 638 } |
639 | 639 |
640 } // namespace chromeos | 640 } // namespace chromeos |
OLD | NEW |