| 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 #include "chrome/browser/chromeos/process_proxy/process_proxy.h" | 5 #include "chrome/browser/chromeos/process_proxy/process_proxy.h" |
| 6 | 6 |
| 7 #include <cstdio> | 7 #include <cstdio> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <signal.h> | 9 #include <signal.h> |
| 10 | 10 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 // |watch| thread is blocked by |output_watcher| from now on. | 90 // |watch| thread is blocked by |output_watcher| from now on. |
| 91 watch_thread->message_loop()->PostTask(FROM_HERE, | 91 watch_thread->message_loop()->PostTask(FROM_HERE, |
| 92 base::Bind(&ProcessOutputWatcher::Start, | 92 base::Bind(&ProcessOutputWatcher::Start, |
| 93 base::Unretained(output_watcher))); | 93 base::Unretained(output_watcher))); |
| 94 watcher_started_ = true; | 94 watcher_started_ = true; |
| 95 return true; | 95 return true; |
| 96 } | 96 } |
| 97 | 97 |
| 98 void ProcessProxy::OnProcessOutput(ProcessOutputType type, | 98 void ProcessProxy::OnProcessOutput(ProcessOutputType type, |
| 99 const std::string& output) { | 99 const std::string& output) { |
| 100 // We have to check if callback is set on FILE thread.. | 100 // We have to check if callback is set on FILE thread.. |
| 101 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)) { | 101 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)) { |
| 102 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, | 102 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, |
| 103 base::Bind(&ProcessProxy::OnProcessOutput, this, type, output)); | 103 base::Bind(&ProcessProxy::OnProcessOutput, this, type, output)); |
| 104 return; | 104 return; |
| 105 } | 105 } |
| 106 | 106 |
| 107 // We may receive some output even after Close was called (crosh process does | 107 // We may receive some output even after Close was called (crosh process does |
| 108 // not have to quit instantly, or there may be some trailing data left in | 108 // not have to quit instantly, or there may be some trailing data left in |
| 109 // output stream fds). In that case owner of the callback may be gone so we | 109 // output stream fds). In that case owner of the callback may be gone so we |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 ClearPipe(in_pipe_); | 213 ClearPipe(in_pipe_); |
| 214 ClearPipe(out_pipe_); | 214 ClearPipe(out_pipe_); |
| 215 ClearPipe(err_pipe_); | 215 ClearPipe(err_pipe_); |
| 216 ClearPipe(shutdown_pipe_); | 216 ClearPipe(shutdown_pipe_); |
| 217 } | 217 } |
| 218 | 218 |
| 219 void ProcessProxy::ClearPipe(int* pipe) { | 219 void ProcessProxy::ClearPipe(int* pipe) { |
| 220 pipe[PIPE_END_READ] = kInvalidFd; | 220 pipe[PIPE_END_READ] = kInvalidFd; |
| 221 pipe[PIPE_END_WRITE] = kInvalidFd; | 221 pipe[PIPE_END_WRITE] = kInvalidFd; |
| 222 } | 222 } |
| OLD | NEW |