Index: ipc/ipc_channel_win.cc |
diff --git a/ipc/ipc_channel_win.cc b/ipc/ipc_channel_win.cc |
index 1442f7fab7b095392510dbe6509c618c49cbffbc..36a42c4d454180021a93b521950caca34890d3e0 100644 |
--- a/ipc/ipc_channel_win.cc |
+++ b/ipc/ipc_channel_win.cc |
@@ -53,6 +53,7 @@ ChannelWin::ChannelWin(const IPC::ChannelHandle& channel_handle, |
} |
ChannelWin::~ChannelWin() { |
+ CleanUp(); |
Close(); |
} |
@@ -74,9 +75,9 @@ void ChannelWin::Close() { |
} |
while (!output_queue_.empty()) { |
- Message* m = output_queue_.front(); |
+ OutputElement* element = output_queue_.front(); |
output_queue_.pop(); |
- delete m; |
+ delete element; |
} |
} |
@@ -123,7 +124,19 @@ bool ChannelWin::ProcessMessageForDelivery(Message* message) { |
message->TraceMessageBegin(); |
// |output_queue_| takes ownership of |message|. |
- output_queue_.push(message); |
+ OutputElement* element = new OutputElement(message); |
+ output_queue_.push(element); |
+ |
+#if USE_ATTACHMENT_BROKER |
+ if (message->HasBrokerableAttachments()) { |
+ // |output_queue_| takes ownership of |ids.buffer|. |
+ Message::SerializedAttachmentIds ids = |
+ message->SerializedIdsOfBrokerableAttachments(); |
+ OutputElement* new_element = new OutputElement(ids.buffer, ids.size); |
+ output_queue_.push(new_element); |
+ } |
+#endif |
+ |
// ensure waiting to write |
if (!waiting_connect_) { |
if (!output_state_.is_pending) { |
@@ -360,7 +373,8 @@ bool ChannelWin::CreatePipe(const IPC::ChannelHandle &channel_handle, |
return false; |
} |
- output_queue_.push(m.release()); |
+ OutputElement* element = new OutputElement(m.release()); |
+ output_queue_.push(element); |
return true; |
} |
@@ -450,9 +464,9 @@ bool ChannelWin::ProcessOutgoingMessages( |
} |
// Message was sent. |
CHECK(!output_queue_.empty()); |
- Message* m = output_queue_.front(); |
+ OutputElement* element = output_queue_.front(); |
output_queue_.pop(); |
- delete m; |
+ delete element; |
} |
if (output_queue_.empty()) |
@@ -462,20 +476,21 @@ bool ChannelWin::ProcessOutgoingMessages( |
return false; |
// Write to pipe... |
- Message* m = output_queue_.front(); |
- DCHECK(m->size() <= INT_MAX); |
- BOOL ok = WriteFile(pipe_.Get(), |
- m->data(), |
- static_cast<uint32>(m->size()), |
- NULL, |
+ OutputElement* element = output_queue_.front(); |
+ DCHECK(element->size() <= INT_MAX); |
+ BOOL ok = WriteFile(pipe_.Get(), element->data(), |
+ static_cast<uint32>(element->size()), NULL, |
&output_state_.context.overlapped); |
if (!ok) { |
DWORD write_error = GetLastError(); |
if (write_error == ERROR_IO_PENDING) { |
output_state_.is_pending = true; |
- DVLOG(2) << "sent pending message @" << m << " on channel @" << this |
- << " with type " << m->type(); |
+ const Message* m = element->get_message(); |
+ if (m) { |
+ DVLOG(2) << "sent pending message @" << m << " on channel @" << this |
+ << " with type " << m->type(); |
+ } |
return true; |
} |
@@ -483,8 +498,11 @@ bool ChannelWin::ProcessOutgoingMessages( |
return false; |
} |
- DVLOG(2) << "sent message @" << m << " on channel @" << this |
- << " with type " << m->type(); |
+ const Message* m = element->get_message(); |
+ if (m) { |
+ DVLOG(2) << "sent message @" << m << " on channel @" << this |
+ << " with type " << m->type(); |
+ } |
output_state_.is_pending = true; |
return true; |