Index: remoting/host/it2me/it2me_native_messaging_host_unittest.cc |
diff --git a/remoting/host/it2me/it2me_native_messaging_host_unittest.cc b/remoting/host/it2me/it2me_native_messaging_host_unittest.cc |
index fa0b088aa88dd8bb4046e90ddd84c93b29b088d1..251598a5ac33f669a49c0eb879a9e7c7cda45a46 100644 |
--- a/remoting/host/it2me/it2me_native_messaging_host_unittest.cc |
+++ b/remoting/host/it2me/it2me_native_messaging_host_unittest.cc |
@@ -17,6 +17,7 @@ |
#include "net/base/net_util.h" |
#include "remoting/base/auto_thread_task_runner.h" |
#include "remoting/host/chromoting_host_context.h" |
+#include "remoting/host/native_messaging/log_message_handler.h" |
#include "remoting/host/native_messaging/native_messaging_pipe.h" |
#include "remoting/host/native_messaging/pipe_messaging_channel.h" |
#include "remoting/host/policy_watcher.h" |
@@ -261,31 +262,38 @@ void It2MeNativeMessagingHostTest::TearDown() { |
scoped_ptr<base::DictionaryValue> |
It2MeNativeMessagingHostTest::ReadMessageFromOutputPipe() { |
- uint32 length; |
- int read_result = output_read_file_.ReadAtCurrentPos( |
- reinterpret_cast<char*>(&length), sizeof(length)); |
- if (read_result != sizeof(length)) { |
- // The output pipe has been closed, return an empty message. |
- return nullptr; |
- } |
+ while (true) { |
+ uint32 length; |
+ int read_result = output_read_file_.ReadAtCurrentPos( |
+ reinterpret_cast<char*>(&length), sizeof(length)); |
+ if (read_result != sizeof(length)) { |
+ // The output pipe has been closed, return an empty message. |
+ return nullptr; |
+ } |
- std::string message_json(length, '\0'); |
- read_result = output_read_file_.ReadAtCurrentPos( |
- string_as_array(&message_json), length); |
- if (read_result != static_cast<int>(length)) { |
- LOG(ERROR) << "Message size (" << read_result |
- << ") doesn't match the header (" << length << ")."; |
- return nullptr; |
- } |
+ std::string message_json(length, '\0'); |
+ read_result = output_read_file_.ReadAtCurrentPos( |
+ string_as_array(&message_json), length); |
+ if (read_result != static_cast<int>(length)) { |
+ LOG(ERROR) << "Message size (" << read_result |
+ << ") doesn't match the header (" << length << ")."; |
+ return nullptr; |
+ } |
- scoped_ptr<base::Value> message = base::JSONReader::Read(message_json); |
- if (!message || !message->IsType(base::Value::TYPE_DICTIONARY)) { |
- LOG(ERROR) << "Malformed message:" << message_json; |
- return nullptr; |
- } |
+ scoped_ptr<base::Value> message = base::JSONReader::Read(message_json); |
+ if (!message || !message->IsType(base::Value::TYPE_DICTIONARY)) { |
+ LOG(ERROR) << "Malformed message:" << message_json; |
+ return nullptr; |
+ } |
- return make_scoped_ptr( |
- static_cast<base::DictionaryValue*>(message.release())); |
+ scoped_ptr<base::DictionaryValue> result = make_scoped_ptr( |
+ static_cast<base::DictionaryValue*>(message.release())); |
+ std::string type; |
+ if (!result->GetString("type", &type) || |
Sergey Ulanov
2015/08/20 21:50:20
Add a comment that we are skipping log messages he
Jamie
2015/08/20 22:29:16
Done.
|
+ type != LogMessageHandler::debug_message_type_name) { |
+ return result; |
+ } |
+ } |
} |
void It2MeNativeMessagingHostTest::WriteMessageToInputPipe( |