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

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

Issue 2656043002: Use explicit WebString conversions in remaining content files (Closed)
Patch Set: build fix Created 3 years, 10 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
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 <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 void WebMessagePortChannelImpl::postMessage( 166 void WebMessagePortChannelImpl::postMessage(
167 const WebString& message, 167 const WebString& message,
168 WebMessagePortChannelArray* channels_ptr) { 168 WebMessagePortChannelArray* channels_ptr) {
169 std::unique_ptr<WebMessagePortChannelArray> channels(channels_ptr); 169 std::unique_ptr<WebMessagePortChannelArray> channels(channels_ptr);
170 if (!main_thread_task_runner_->BelongsToCurrentThread()) { 170 if (!main_thread_task_runner_->BelongsToCurrentThread()) {
171 // Note: we must construct the base::string16 here and pass that. Otherwise, 171 // Note: we must construct the base::string16 here and pass that. Otherwise,
172 // the WebString will be passed, leading to references to the StringImpl 172 // the WebString will be passed, leading to references to the StringImpl
173 // from two threads, which is a data race. 173 // from two threads, which is a data race.
174 main_thread_task_runner_->PostTask( 174 main_thread_task_runner_->PostTask(
175 FROM_HERE, base::Bind(&WebMessagePortChannelImpl::SendPostMessage, this, 175 FROM_HERE, base::Bind(&WebMessagePortChannelImpl::SendPostMessage, this,
176 base::Passed(base::string16(message)), 176 base::Passed(message.utf16()),
177 base::Passed(std::move(channels)))); 177 base::Passed(std::move(channels))));
178 } else { 178 } else {
179 SendPostMessage(message, std::move(channels)); 179 SendPostMessage(message.utf16(), std::move(channels));
180 } 180 }
181 } 181 }
182 182
183 void WebMessagePortChannelImpl::SendPostMessage( 183 void WebMessagePortChannelImpl::SendPostMessage(
184 const base::string16& message, 184 const base::string16& message,
185 std::unique_ptr<WebMessagePortChannelArray> channels) { 185 std::unique_ptr<WebMessagePortChannelArray> channels) {
186 IPC::Message* msg = new MessagePortHostMsg_PostMessage( 186 IPC::Message* msg = new MessagePortHostMsg_PostMessage(
187 message_port_id_, message, ExtractMessagePortIDs(std::move(channels))); 187 message_port_id_, message, ExtractMessagePortIDs(std::move(channels)));
188 Send(msg); 188 Send(msg);
189 } 189 }
190 190
191 bool WebMessagePortChannelImpl::tryGetMessage( 191 bool WebMessagePortChannelImpl::tryGetMessage(
192 WebString* message, 192 WebString* message,
193 WebMessagePortChannelArray& channels) { 193 WebMessagePortChannelArray& channels) {
194 base::AutoLock auto_lock(lock_); 194 base::AutoLock auto_lock(lock_);
195 if (message_queue_.empty()) 195 if (message_queue_.empty())
196 return false; 196 return false;
197 197
198 *message = message_queue_.front().message; 198 *message = WebString::fromUTF16(message_queue_.front().message);
199 channels = message_queue_.front().ports; 199 channels = message_queue_.front().ports;
200 message_queue_.pop(); 200 message_queue_.pop();
201 return true; 201 return true;
202 } 202 }
203 203
204 void WebMessagePortChannelImpl::Init() { 204 void WebMessagePortChannelImpl::Init() {
205 if (!main_thread_task_runner_->BelongsToCurrentThread()) { 205 if (!main_thread_task_runner_->BelongsToCurrentThread()) {
206 main_thread_task_runner_->PostTask( 206 main_thread_task_runner_->PostTask(
207 FROM_HERE, base::Bind(&WebMessagePortChannelImpl::Init, this)); 207 FROM_HERE, base::Bind(&WebMessagePortChannelImpl::Init, this));
208 return; 208 return;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 ChildProcess::current()->ReleaseProcess(); 316 ChildProcess::current()->ReleaseProcess();
317 } 317 }
318 318
319 WebMessagePortChannelImpl::Message::Message() {} 319 WebMessagePortChannelImpl::Message::Message() {}
320 320
321 WebMessagePortChannelImpl::Message::Message(const Message& other) = default; 321 WebMessagePortChannelImpl::Message::Message(const Message& other) = default;
322 322
323 WebMessagePortChannelImpl::Message::~Message() {} 323 WebMessagePortChannelImpl::Message::~Message() {}
324 324
325 } // namespace content 325 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698