| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_CHROMEOS_PROCESS_PROXY_PROCESS_OUTPUT_WATCHER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_PROCESS_PROXY_PROCESS_OUTPUT_WATCHER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_PROCESS_PROXY_PROCESS_OUTPUT_WATCHER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_PROCESS_PROXY_PROCESS_OUTPUT_WATCHER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 const int kReadBufferSize = 256; | 15 const int kReadBufferSize = 256; |
| 16 | 16 |
| 17 } // namespace | 17 } // namespace |
| 18 | 18 |
| 19 enum ProcessOutputType { | 19 enum ProcessOutputType { |
| 20 PROCESS_OUTPUT_TYPE_OUT, | 20 PROCESS_OUTPUT_TYPE_OUT, |
| 21 PROCESS_OUTPUT_TYPE_ERR | 21 PROCESS_OUTPUT_TYPE_ERR |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 typedef base::Callback<void(ProcessOutputType, std::string)> | 24 typedef base::Callback<void(ProcessOutputType, const std::string&)> |
| 25 ProcessOutputCallback; | 25 ProcessOutputCallback; |
| 26 | 26 |
| 27 // This class should live on its own thread because running class makes | 27 // This class should live on its own thread because running class makes |
| 28 // underlying thread block. It deletes itself when watching is stopped. | 28 // underlying thread block. It deletes itself when watching is stopped. |
| 29 class ProcessOutputWatcher { | 29 class ProcessOutputWatcher { |
| 30 public: | 30 public: |
| 31 ProcessOutputWatcher(int out_fd, int err_fd, int stop_fd, | 31 ProcessOutputWatcher(int out_fd, int err_fd, int stop_fd, |
| 32 const ProcessOutputCallback& callback); | 32 const ProcessOutputCallback& callback); |
| 33 | 33 |
| 34 // This will block current thread!!!! | 34 // This will block current thread!!!! |
| (...skipping 24 matching lines...) Expand all Loading... |
| 59 int err_fd_; | 59 int err_fd_; |
| 60 int stop_fd_; | 60 int stop_fd_; |
| 61 int max_fd_; | 61 int max_fd_; |
| 62 | 62 |
| 63 // Callback that will be invoked when some output is detected. | 63 // Callback that will be invoked when some output is detected. |
| 64 ProcessOutputCallback on_read_callback_; | 64 ProcessOutputCallback on_read_callback_; |
| 65 | 65 |
| 66 DISALLOW_COPY_AND_ASSIGN(ProcessOutputWatcher); | 66 DISALLOW_COPY_AND_ASSIGN(ProcessOutputWatcher); |
| 67 }; | 67 }; |
| 68 #endif // CHROME_BROWSER_CHROMEOS_PROCESS_PROXY_PROCESS_OUTPUT_WATCHER_H_ | 68 #endif // CHROME_BROWSER_CHROMEOS_PROCESS_PROXY_PROCESS_OUTPUT_WATCHER_H_ |
| OLD | NEW |