Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Unified Diff: remoting/host/setup/native_messaging_reader.cc

Issue 14979008: unittests for Chromoting native messaging host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename pipe.h->test_util.h, and fix Windows test failure Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/host/setup/native_messaging_reader.cc
diff --git a/remoting/host/setup/native_messaging_reader.cc b/remoting/host/setup/native_messaging_reader.cc
index e98ac52ff18e53350959e7fa7a53af71f053f802..71516533f1b033bcac708cda0948dcb44d187fc9 100644
--- a/remoting/host/setup/native_messaging_reader.cc
+++ b/remoting/host/setup/native_messaging_reader.cc
@@ -73,8 +73,7 @@ NativeMessagingReader::Core::Core(
read_task_runner_(read_task_runner) {
}
-NativeMessagingReader::Core::~Core() {
-}
+NativeMessagingReader::Core::~Core() {}
void NativeMessagingReader::Core::ReadMessage() {
DCHECK(read_task_runner_->RunsTasksOnCurrentThread());
@@ -85,8 +84,11 @@ void NativeMessagingReader::Core::ReadMessage() {
int read_result = read_stream_.ReadUntilComplete(
reinterpret_cast<char*>(&message_length), kMessageHeaderSize);
if (read_result != kMessageHeaderSize) {
- LOG(ERROR) << "Failed to read message header, read returned "
- << read_result;
+ // 0 means EOF which is normal and should not be logged as an error.
+ if (read_result != 0) {
+ LOG(ERROR) << "Failed to read message header, read returned "
+ << read_result;
+ }
NotifyEof();
return;
}
@@ -98,8 +100,8 @@ void NativeMessagingReader::Core::ReadMessage() {
}
std::string message_json(message_length, '\0');
- read_result = read_stream_.ReadUntilComplete(
- string_as_array(&message_json), message_length);
+ read_result = read_stream_.ReadUntilComplete(string_as_array(&message_json),
+ message_length);
if (read_result != static_cast<int>(message_length)) {
LOG(ERROR) << "Failed to read message body, read returned "
<< read_result;
@@ -115,16 +117,17 @@ void NativeMessagingReader::Core::ReadMessage() {
}
// Notify callback of new message.
- caller_task_runner_->PostTask(FROM_HERE, base::Bind(
- &NativeMessagingReader::InvokeMessageCallback, reader_,
- base::Passed(&message)));
+ caller_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&NativeMessagingReader::InvokeMessageCallback,
+ reader_, base::Passed(&message)));
}
}
void NativeMessagingReader::Core::NotifyEof() {
DCHECK(read_task_runner_->RunsTasksOnCurrentThread());
- caller_task_runner_->PostTask(FROM_HERE, base::Bind(
- &NativeMessagingReader::InvokeEofCallback, reader_));
+ caller_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&NativeMessagingReader::InvokeEofCallback, reader_));
}
NativeMessagingReader::NativeMessagingReader(base::PlatformFile handle)
@@ -147,9 +150,9 @@ void NativeMessagingReader::Start(MessageCallback message_callback,
// base::Unretained is safe since |core_| is only deleted via the
// DeleteSoon task which is posted from this class's dtor.
- read_task_runner_->PostTask(FROM_HERE, base::Bind(
- &NativeMessagingReader::Core::ReadMessage,
- base::Unretained(core_.get())));
+ read_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&NativeMessagingReader::Core::ReadMessage,
+ base::Unretained(core_.get())));
}
void NativeMessagingReader::InvokeMessageCallback(
« no previous file with comments | « remoting/host/setup/native_messaging_host_unittest.cc ('k') | remoting/host/setup/native_messaging_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698