| 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 "ipc/ipc_channel_reader.h" | 5 #include "ipc/ipc_channel_reader.h" |
| 6 | 6 |
| 7 #include "ipc/ipc_logging.h" |
| 8 #include "ipc/ipc_message_macros.h" |
| 9 |
| 7 namespace IPC { | 10 namespace IPC { |
| 8 namespace internal { | 11 namespace internal { |
| 9 | 12 |
| 10 ChannelReader::ChannelReader(Listener* listener) : listener_(listener) { | 13 ChannelReader::ChannelReader(Listener* listener) : listener_(listener) { |
| 11 memset(input_buf_, 0, sizeof(input_buf_)); | 14 memset(input_buf_, 0, sizeof(input_buf_)); |
| 12 } | 15 } |
| 13 | 16 |
| 14 ChannelReader::~ChannelReader() { | 17 ChannelReader::~ChannelReader() { |
| 15 } | 18 } |
| 16 | 19 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 65 |
| 63 // Dispatch all complete messages in the data buffer. | 66 // Dispatch all complete messages in the data buffer. |
| 64 while (p < end) { | 67 while (p < end) { |
| 65 const char* message_tail = Message::FindNext(p, end); | 68 const char* message_tail = Message::FindNext(p, end); |
| 66 if (message_tail) { | 69 if (message_tail) { |
| 67 int len = static_cast<int>(message_tail - p); | 70 int len = static_cast<int>(message_tail - p); |
| 68 Message m(p, len); | 71 Message m(p, len); |
| 69 if (!WillDispatchInputMessage(&m)) | 72 if (!WillDispatchInputMessage(&m)) |
| 70 return false; | 73 return false; |
| 71 | 74 |
| 72 m.TraceMessageStep(); | 75 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 76 Logging* logger = Logging::GetInstance(); |
| 77 std::string name; |
| 78 logger->GetMessageText(m.type(), &name, &m, NULL); |
| 79 TRACE_EVENT1("ipc", "ChannelReader::DispatchInputData", "name", name); |
| 80 #else |
| 81 TRACE_EVENT2("ipc", "ChannelReader::DispatchInputData", |
| 82 "class", IPC_MESSAGE_ID_CLASS(m.type()), |
| 83 "line", IPC_MESSAGE_ID_LINE(m.type())); |
| 84 #endif |
| 85 m.TraceMessageEnd(); |
| 73 if (IsHelloMessage(m)) | 86 if (IsHelloMessage(m)) |
| 74 HandleHelloMessage(m); | 87 HandleHelloMessage(m); |
| 75 else | 88 else |
| 76 listener_->OnMessageReceived(m); | 89 listener_->OnMessageReceived(m); |
| 77 p = message_tail; | 90 p = message_tail; |
| 78 } else { | 91 } else { |
| 79 // Last message is partial. | 92 // Last message is partial. |
| 80 break; | 93 break; |
| 81 } | 94 } |
| 82 } | 95 } |
| 83 | 96 |
| 84 // Save any partial data in the overflow buffer. | 97 // Save any partial data in the overflow buffer. |
| 85 input_overflow_buf_.assign(p, end - p); | 98 input_overflow_buf_.assign(p, end - p); |
| 86 | 99 |
| 87 if (input_overflow_buf_.empty() && !DidEmptyInputBuffers()) | 100 if (input_overflow_buf_.empty() && !DidEmptyInputBuffers()) |
| 88 return false; | 101 return false; |
| 89 return true; | 102 return true; |
| 90 } | 103 } |
| 91 | 104 |
| 92 | 105 |
| 93 } // namespace internal | 106 } // namespace internal |
| 94 } // namespace IPC | 107 } // namespace IPC |
| OLD | NEW |