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

Side by Side Diff: ipc/ipc_channel_reader.cc

Issue 1308613006: ipc: Update Message::FindNext to parse brokered attachments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | ipc/ipc_message.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "ipc/ipc_listener.h" 9 #include "ipc/ipc_listener.h"
10 #include "ipc/ipc_logging.h" 10 #include "ipc/ipc_logging.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 LOG(ERROR) << "IPC message is too big"; 78 LOG(ERROR) << "IPC message is too big";
79 return false; 79 return false;
80 } 80 }
81 input_overflow_buf_.append(input_data, input_data_len); 81 input_overflow_buf_.append(input_data, input_data_len);
82 p = input_overflow_buf_.data(); 82 p = input_overflow_buf_.data();
83 end = p + input_overflow_buf_.size(); 83 end = p + input_overflow_buf_.size();
84 } 84 }
85 85
86 // Dispatch all complete messages in the data buffer. 86 // Dispatch all complete messages in the data buffer.
87 while (p < end) { 87 while (p < end) {
88 const char* message_tail = Message::FindNext(p, end); 88 Message::NextMessageInfo info;
89 if (message_tail) { 89 Message::FindNext(p, end, &info);
90 int len = static_cast<int>(message_tail - p); 90 if (info.message_found) {
91 int pickle_len = static_cast<int>(info.pickle_end - p);
92 Message translated_message(p, pickle_len);
91 93
92 Message translated_message(p, len); 94 // TODO(erikchen): Make attachments for info.attachment_ids.
95 // http://crbug.com/493414.
96
93 if (!GetNonBrokeredAttachments(&translated_message)) 97 if (!GetNonBrokeredAttachments(&translated_message))
94 return false; 98 return false;
95 99
96 // If there are no queued messages, attempt to immediately dispatch the 100 // If there are no queued messages, attempt to immediately dispatch the
97 // newly translated message. 101 // newly translated message.
98 if (queued_messages_.empty()) { 102 if (queued_messages_.empty()) {
99 DCHECK(blocked_ids_.empty()); 103 DCHECK(blocked_ids_.empty());
100 AttachmentIdSet blocked_ids = 104 AttachmentIdSet blocked_ids =
101 GetBrokeredAttachments(&translated_message); 105 GetBrokeredAttachments(&translated_message);
102 106
103 if (blocked_ids.empty()) { 107 if (blocked_ids.empty()) {
104 // Dispatch the message and continue the loop. 108 // Dispatch the message and continue the loop.
105 DispatchMessage(&translated_message); 109 DispatchMessage(&translated_message);
106 p = message_tail; 110 p = info.message_end;
107 continue; 111 continue;
108 } 112 }
109 113
110 blocked_ids_.swap(blocked_ids); 114 blocked_ids_.swap(blocked_ids);
111 StartObservingAttachmentBroker(); 115 StartObservingAttachmentBroker();
112 } 116 }
113 117
114 // Make a deep copy of |translated_message| to add to the queue. 118 // Make a deep copy of |translated_message| to add to the queue.
115 scoped_ptr<Message> m(new Message(translated_message)); 119 scoped_ptr<Message> m(new Message(translated_message));
116 queued_messages_.push_back(m.release()); 120 queued_messages_.push_back(m.release());
117 p = message_tail; 121 p = info.message_end;
118 } else { 122 } else {
119 // Last message is partial. 123 // Last message is partial.
120 break; 124 break;
121 } 125 }
122 } 126 }
123 127
124 // Save any partial data in the overflow buffer. 128 // Save any partial data in the overflow buffer.
125 input_overflow_buf_.assign(p, end - p); 129 input_overflow_buf_.assign(p, end - p);
126 130
127 if (input_overflow_buf_.empty() && !DidEmptyInputBuffers()) 131 if (input_overflow_buf_.empty() && !DidEmptyInputBuffers())
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } 237 }
234 238
235 void ChannelReader::StopObservingAttachmentBroker() { 239 void ChannelReader::StopObservingAttachmentBroker() {
236 #if USE_ATTACHMENT_BROKER 240 #if USE_ATTACHMENT_BROKER
237 GetAttachmentBroker()->RemoveObserver(this); 241 GetAttachmentBroker()->RemoveObserver(this);
238 #endif // USE_ATTACHMENT_BROKER 242 #endif // USE_ATTACHMENT_BROKER
239 } 243 }
240 244
241 } // namespace internal 245 } // namespace internal
242 } // namespace IPC 246 } // namespace IPC
OLDNEW
« no previous file with comments | « no previous file | ipc/ipc_message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698