| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_win.h" | 5 #include "ipc/ipc_channel_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <sddl.h> | 8 #include <sddl.h> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 | 10 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 while (!output_queue_.empty()) { | 141 while (!output_queue_.empty()) { |
| 142 Message* m = output_queue_.front(); | 142 Message* m = output_queue_.front(); |
| 143 output_queue_.pop(); | 143 output_queue_.pop(); |
| 144 delete m; | 144 delete m; |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 bool Channel::ChannelImpl::Send(Message* message) { | 148 bool Channel::ChannelImpl::Send(Message* message) { |
| 149 DCHECK(thread_check_->CalledOnValidThread()); | 149 DCHECK(thread_check_->CalledOnValidThread()); |
| 150 #ifdef IPC_MESSAGE_DEBUG_EXTRA | 150 DVLOG(2) << "sending message @" << message << " on channel @" << this |
| 151 DLOG(INFO) << "sending message @" << message << " on channel @" << this | 151 << " with type " << message->type() |
| 152 << " with type " << message->type() | 152 << " (" << output_queue_.size() << " in queue)"; |
| 153 << " (" << output_queue_.size() << " in queue)"; | |
| 154 #endif | |
| 155 | 153 |
| 156 #ifdef IPC_MESSAGE_LOG_ENABLED | 154 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 157 Logging::current()->OnSendMessage(message, ""); | 155 Logging::current()->OnSendMessage(message, ""); |
| 158 #endif | 156 #endif |
| 159 | 157 |
| 160 output_queue_.push(message); | 158 output_queue_.push(message); |
| 161 // ensure waiting to write | 159 // ensure waiting to write |
| 162 if (!waiting_connect_) { | 160 if (!waiting_connect_) { |
| 163 if (!output_state_.is_pending) { | 161 if (!output_state_.is_pending) { |
| 164 if (!ProcessOutgoingMessages(NULL, 0)) | 162 if (!ProcessOutgoingMessages(NULL, 0)) |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 input_overflow_buf_.append(input_buf_, bytes_read); | 351 input_overflow_buf_.append(input_buf_, bytes_read); |
| 354 p = input_overflow_buf_.data(); | 352 p = input_overflow_buf_.data(); |
| 355 end = p + input_overflow_buf_.size(); | 353 end = p + input_overflow_buf_.size(); |
| 356 } | 354 } |
| 357 | 355 |
| 358 while (p < end) { | 356 while (p < end) { |
| 359 const char* message_tail = Message::FindNext(p, end); | 357 const char* message_tail = Message::FindNext(p, end); |
| 360 if (message_tail) { | 358 if (message_tail) { |
| 361 int len = static_cast<int>(message_tail - p); | 359 int len = static_cast<int>(message_tail - p); |
| 362 const Message m(p, len); | 360 const Message m(p, len); |
| 363 #ifdef IPC_MESSAGE_DEBUG_EXTRA | 361 DVLOG(2) << "received message on channel @" << this |
| 364 DLOG(INFO) << "received message on channel @" << this << | 362 << " with type " << m.type(); |
| 365 " with type " << m.type(); | |
| 366 #endif | |
| 367 if (m.routing_id() == MSG_ROUTING_NONE && | 363 if (m.routing_id() == MSG_ROUTING_NONE && |
| 368 m.type() == HELLO_MESSAGE_TYPE) { | 364 m.type() == HELLO_MESSAGE_TYPE) { |
| 369 // The Hello message contains only the process id. | 365 // The Hello message contains only the process id. |
| 370 listener_->OnChannelConnected(MessageIterator(m).NextInt()); | 366 listener_->OnChannelConnected(MessageIterator(m).NextInt()); |
| 371 } else { | 367 } else { |
| 372 listener_->OnMessageReceived(m); | 368 listener_->OnMessageReceived(m); |
| 373 } | 369 } |
| 374 p = message_tail; | 370 p = message_tail; |
| 375 } else { | 371 } else { |
| 376 // Last message is partial. | 372 // Last message is partial. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 BOOL ok = WriteFile(pipe_, | 414 BOOL ok = WriteFile(pipe_, |
| 419 m->data(), | 415 m->data(), |
| 420 m->size(), | 416 m->size(), |
| 421 &bytes_written, | 417 &bytes_written, |
| 422 &output_state_.context.overlapped); | 418 &output_state_.context.overlapped); |
| 423 if (!ok) { | 419 if (!ok) { |
| 424 DWORD err = GetLastError(); | 420 DWORD err = GetLastError(); |
| 425 if (err == ERROR_IO_PENDING) { | 421 if (err == ERROR_IO_PENDING) { |
| 426 output_state_.is_pending = true; | 422 output_state_.is_pending = true; |
| 427 | 423 |
| 428 #ifdef IPC_MESSAGE_DEBUG_EXTRA | 424 DVLOG(2) << "sent pending message @" << m << " on channel @" << this |
| 429 DLOG(INFO) << "sent pending message @" << m << " on channel @" << | 425 << " with type " << m->type(); |
| 430 this << " with type " << m->type(); | |
| 431 #endif | |
| 432 | 426 |
| 433 return true; | 427 return true; |
| 434 } | 428 } |
| 435 LOG(ERROR) << "pipe error: " << err; | 429 LOG(ERROR) << "pipe error: " << err; |
| 436 return false; | 430 return false; |
| 437 } | 431 } |
| 438 | 432 |
| 439 #ifdef IPC_MESSAGE_DEBUG_EXTRA | 433 DVLOG(2) << "sent message @" << m << " on channel @" << this |
| 440 DLOG(INFO) << "sent message @" << m << " on channel @" << this << | 434 << " with type " << m->type(); |
| 441 " with type " << m->type(); | |
| 442 #endif | |
| 443 | 435 |
| 444 output_state_.is_pending = true; | 436 output_state_.is_pending = true; |
| 445 return true; | 437 return true; |
| 446 } | 438 } |
| 447 | 439 |
| 448 void Channel::ChannelImpl::OnIOCompleted(MessageLoopForIO::IOContext* context, | 440 void Channel::ChannelImpl::OnIOCompleted(MessageLoopForIO::IOContext* context, |
| 449 DWORD bytes_transfered, DWORD error) { | 441 DWORD bytes_transfered, DWORD error) { |
| 450 bool ok; | 442 bool ok; |
| 451 DCHECK(thread_check_->CalledOnValidThread()); | 443 DCHECK(thread_check_->CalledOnValidThread()); |
| 452 if (context == &input_state_.context) { | 444 if (context == &input_state_.context) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 | 488 |
| 497 void Channel::set_listener(Listener* listener) { | 489 void Channel::set_listener(Listener* listener) { |
| 498 channel_impl_->set_listener(listener); | 490 channel_impl_->set_listener(listener); |
| 499 } | 491 } |
| 500 | 492 |
| 501 bool Channel::Send(Message* message) { | 493 bool Channel::Send(Message* message) { |
| 502 return channel_impl_->Send(message); | 494 return channel_impl_->Send(message); |
| 503 } | 495 } |
| 504 | 496 |
| 505 } // namespace IPC | 497 } // namespace IPC |
| OLD | NEW |