Index: chrome/browser/extensions/api/messaging/native_message_process_host_posix.cc |
diff --git a/chrome/browser/extensions/api/messaging/native_message_process_host_posix.cc b/chrome/browser/extensions/api/messaging/native_message_process_host_posix.cc |
index 00f7e80744a5b0415d7f5113ff66189e7b0f084c..2dd6784b13246c6a6f6e543a8c4953408a5338d3 100644 |
--- a/chrome/browser/extensions/api/messaging/native_message_process_host_posix.cc |
+++ b/chrome/browser/extensions/api/messaging/native_message_process_host_posix.cc |
@@ -25,8 +25,34 @@ void NativeMessageProcessHost::InitIO() { |
this); |
} |
+void NativeMessageProcessHost::StopIO() { |
+ read_watcher_.StopWatchingFileDescriptor(); |
+} |
+ |
+bool NativeMessageProcessHost::ReadMessage(MessageType* type, |
+ std::string* message) { |
+ // Read the type (uint32) and length (uint32). |
+ char message_meta_data[8]; |
+ if (!file_util::ReadFromFD(read_file_, message_meta_data, 8)) { |
+ LOG(ERROR) << "Error reading the message type and length."; |
+ return false; |
+ } |
+ |
+ uint32 message_length; |
+ if (!VerifyMessageMetaData(message_meta_data, type, &message_length)) |
+ return false; |
+ |
+ message->resize(message_length, '\0'); |
+ if (!file_util::ReadFromFD(read_file_, &(*message)[0], message_length)) { |
+ LOG(ERROR) << "Error reading the json data."; |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
void NativeMessageProcessHost::OnFileCanReadWithoutBlocking(int fd) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
// Make sure that the fd given to us is the same one we started with. |
CHECK_EQ(fd, read_file_); |
@@ -62,10 +88,4 @@ bool NativeMessageProcessHost::WriteData(FileHandle file, |
return file_util::WriteFileDescriptor(file, data, bytes_to_write); |
} |
-bool NativeMessageProcessHost::ReadData(FileHandle file, |
- char* data, |
- size_t bytes_to_read) { |
- return file_util::ReadFromFD(file, data, bytes_to_read); |
-} |
- |
} // namespace extensions |