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

Side by Side Diff: content/child/webmessageportchannel_impl.cc

Issue 102593002: Convert string16 to base::string16 in content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « content/child/webmessageportchannel_impl.h ('k') | content/common/android/address_parser.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/child/webmessageportchannel_impl.h" 5 #include "content/child/webmessageportchannel_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "content/child/child_process.h" 9 #include "content/child/child_process.h"
10 #include "content/child/child_thread.h" 10 #include "content/child/child_thread.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 bool handled = true; 195 bool handled = true;
196 IPC_BEGIN_MESSAGE_MAP(WebMessagePortChannelImpl, message) 196 IPC_BEGIN_MESSAGE_MAP(WebMessagePortChannelImpl, message)
197 IPC_MESSAGE_HANDLER(MessagePortMsg_Message, OnMessage) 197 IPC_MESSAGE_HANDLER(MessagePortMsg_Message, OnMessage)
198 IPC_MESSAGE_HANDLER(MessagePortMsg_MessagesQueued, OnMessagesQueued) 198 IPC_MESSAGE_HANDLER(MessagePortMsg_MessagesQueued, OnMessagesQueued)
199 IPC_MESSAGE_UNHANDLED(handled = false) 199 IPC_MESSAGE_UNHANDLED(handled = false)
200 IPC_END_MESSAGE_MAP() 200 IPC_END_MESSAGE_MAP()
201 return handled; 201 return handled;
202 } 202 }
203 203
204 void WebMessagePortChannelImpl::OnMessage( 204 void WebMessagePortChannelImpl::OnMessage(
205 const string16& message, 205 const base::string16& message,
206 const std::vector<int>& sent_message_port_ids, 206 const std::vector<int>& sent_message_port_ids,
207 const std::vector<int>& new_routing_ids) { 207 const std::vector<int>& new_routing_ids) {
208 base::AutoLock auto_lock(lock_); 208 base::AutoLock auto_lock(lock_);
209 Message msg; 209 Message msg;
210 msg.message = message; 210 msg.message = message;
211 if (!sent_message_port_ids.empty()) { 211 if (!sent_message_port_ids.empty()) {
212 msg.ports.resize(sent_message_port_ids.size()); 212 msg.ports.resize(sent_message_port_ids.size());
213 for (size_t i = 0; i < sent_message_port_ids.size(); ++i) { 213 for (size_t i = 0; i < sent_message_port_ids.size(); ++i) {
214 msg.ports[i] = new WebMessagePortChannelImpl(new_routing_ids[i], 214 msg.ports[i] = new WebMessagePortChannelImpl(new_routing_ids[i],
215 sent_message_port_ids[i], 215 sent_message_port_ids[i],
216 child_thread_loop_.get()); 216 child_thread_loop_.get());
217 } 217 }
218 } 218 }
219 219
220 bool was_empty = message_queue_.empty(); 220 bool was_empty = message_queue_.empty();
221 message_queue_.push(msg); 221 message_queue_.push(msg);
222 if (client_ && was_empty) 222 if (client_ && was_empty)
223 client_->messageAvailable(); 223 client_->messageAvailable();
224 } 224 }
225 225
226 void WebMessagePortChannelImpl::OnMessagesQueued() { 226 void WebMessagePortChannelImpl::OnMessagesQueued() {
227 std::vector<QueuedMessage> queued_messages; 227 std::vector<QueuedMessage> queued_messages;
228 228
229 { 229 {
230 base::AutoLock auto_lock(lock_); 230 base::AutoLock auto_lock(lock_);
231 queued_messages.reserve(message_queue_.size()); 231 queued_messages.reserve(message_queue_.size());
232 while (!message_queue_.empty()) { 232 while (!message_queue_.empty()) {
233 string16 message = message_queue_.front().message; 233 base::string16 message = message_queue_.front().message;
234 const std::vector<WebMessagePortChannelImpl*>& channel_array = 234 const std::vector<WebMessagePortChannelImpl*>& channel_array =
235 message_queue_.front().ports; 235 message_queue_.front().ports;
236 std::vector<int> port_ids(channel_array.size()); 236 std::vector<int> port_ids(channel_array.size());
237 for (size_t i = 0; i < channel_array.size(); ++i) { 237 for (size_t i = 0; i < channel_array.size(); ++i) {
238 port_ids[i] = channel_array[i]->message_port_id(); 238 port_ids[i] = channel_array[i]->message_port_id();
239 channel_array[i]->QueueMessages(); 239 channel_array[i]->QueueMessages();
240 } 240 }
241 queued_messages.push_back(std::make_pair(message, port_ids)); 241 queued_messages.push_back(std::make_pair(message, port_ids));
242 message_queue_.pop(); 242 message_queue_.pop();
243 } 243 }
244 } 244 }
245 245
246 Send(new MessagePortHostMsg_SendQueuedMessages( 246 Send(new MessagePortHostMsg_SendQueuedMessages(
247 message_port_id_, queued_messages)); 247 message_port_id_, queued_messages));
248 248
249 message_port_id_ = MSG_ROUTING_NONE; 249 message_port_id_ = MSG_ROUTING_NONE;
250 250
251 Release(); 251 Release();
252 ChildProcess::current()->ReleaseProcess(); 252 ChildProcess::current()->ReleaseProcess();
253 } 253 }
254 254
255 WebMessagePortChannelImpl::Message::Message() {} 255 WebMessagePortChannelImpl::Message::Message() {}
256 256
257 WebMessagePortChannelImpl::Message::~Message() {} 257 WebMessagePortChannelImpl::Message::~Message() {}
258 258
259 } // namespace content 259 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webmessageportchannel_impl.h ('k') | content/common/android/address_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698