| 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 "chrome/browser/extensions/api/messaging/native_message_process_host.h" | 5 #include "chrome/browser/extensions/api/messaging/native_message_process_host.h" | 
| 6 | 6 | 
| 7 #include "base/bind.h" | 7 #include "base/bind.h" | 
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" | 
| 9 #include "base/logging.h" | 9 #include "base/logging.h" | 
| 10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" | 
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 241   DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 241   DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 
| 242 | 242 | 
| 243   if (closed_) | 243   if (closed_) | 
| 244     return; | 244     return; | 
| 245 | 245 | 
| 246   if (result > 0) { | 246   if (result > 0) { | 
| 247     ProcessIncomingData(read_buffer_->data(), result); | 247     ProcessIncomingData(read_buffer_->data(), result); | 
| 248   } else if (result == net::ERR_IO_PENDING) { | 248   } else if (result == net::ERR_IO_PENDING) { | 
| 249     read_pending_ = true; | 249     read_pending_ = true; | 
| 250   } else if (result == 0 || result == net::ERR_CONNECTION_RESET) { | 250   } else if (result == 0 || result == net::ERR_CONNECTION_RESET) { | 
|  | 251     // On Windows we get net::ERR_CONNECTION_RESET for a broken pipe, while on | 
|  | 252     // Posix read() returns 0 in that case. | 
| 251     Close(kNativeHostExited); | 253     Close(kNativeHostExited); | 
| 252   } else { | 254   } else { | 
| 253     LOG(ERROR) << "Error when reading from Native Messaging host: " << result; | 255     LOG(ERROR) << "Error when reading from Native Messaging host: " << result; | 
| 254     Close(kHostInputOuputError); | 256     Close(kHostInputOuputError); | 
| 255   } | 257   } | 
| 256 } | 258 } | 
| 257 | 259 | 
| 258 void NativeMessageProcessHost::ProcessIncomingData( | 260 void NativeMessageProcessHost::ProcessIncomingData( | 
| 259     const char* data, int data_size) { | 261     const char* data, int data_size) { | 
| 260   DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 262   DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 342     closed_ = true; | 344     closed_ = true; | 
| 343     read_stream_.reset(); | 345     read_stream_.reset(); | 
| 344     write_stream_.reset(); | 346     write_stream_.reset(); | 
| 345     content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 347     content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 
| 346         base::Bind(&Client::CloseChannel, weak_client_ui_, | 348         base::Bind(&Client::CloseChannel, weak_client_ui_, | 
| 347                    destination_port_, error_message)); | 349                    destination_port_, error_message)); | 
| 348   } | 350   } | 
| 349 } | 351 } | 
| 350 | 352 | 
| 351 }  // namespace extensions | 353 }  // namespace extensions | 
| OLD | NEW | 
|---|