| OLD | NEW |
| 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 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 11 #include "content/child/child_process.h" | 12 #include "content/child/child_process.h" |
| 12 #include "content/child/child_thread_impl.h" | 13 #include "content/child/child_thread_impl.h" |
| 13 #include "content/common/message_port_messages.h" | 14 #include "content/common/message_port_messages.h" |
| 14 #include "content/public/child/v8_value_converter.h" | 15 #include "content/public/child/v8_value_converter.h" |
| 15 #include "third_party/WebKit/public/platform/WebMessagePortChannelClient.h" | 16 #include "third_party/WebKit/public/platform/WebMessagePortChannelClient.h" |
| 16 #include "third_party/WebKit/public/platform/WebString.h" | 17 #include "third_party/WebKit/public/platform/WebString.h" |
| 17 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" | 18 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 scoped_ptr<WebMessagePortChannelArray> channels(channels_ptr); | 178 scoped_ptr<WebMessagePortChannelArray> channels(channels_ptr); |
| 178 if (send_messages_as_values_) { | 179 if (send_messages_as_values_) { |
| 179 blink::WebSerializedScriptValue serialized_value = | 180 blink::WebSerializedScriptValue serialized_value = |
| 180 blink::WebSerializedScriptValue::fromString(message_as_string); | 181 blink::WebSerializedScriptValue::fromString(message_as_string); |
| 181 v8::Local<v8::Value> v8_value = serialized_value.deserialize(); | 182 v8::Local<v8::Value> v8_value = serialized_value.deserialize(); |
| 182 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 183 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); |
| 183 converter->SetDateAllowed(true); | 184 converter->SetDateAllowed(true); |
| 184 converter->SetRegExpAllowed(true); | 185 converter->SetRegExpAllowed(true); |
| 185 scoped_ptr<base::Value> message_as_value(converter->FromV8Value( | 186 scoped_ptr<base::Value> message_as_value(converter->FromV8Value( |
| 186 v8_value, v8::Isolate::GetCurrent()->GetCurrentContext())); | 187 v8_value, v8::Isolate::GetCurrent()->GetCurrentContext())); |
| 187 message = MessagePortMessage(message_as_value.Pass()); | 188 message = MessagePortMessage(std::move(message_as_value)); |
| 188 } | 189 } |
| 189 if (!main_thread_task_runner_->BelongsToCurrentThread()) { | 190 if (!main_thread_task_runner_->BelongsToCurrentThread()) { |
| 190 main_thread_task_runner_->PostTask( | 191 main_thread_task_runner_->PostTask( |
| 191 FROM_HERE, base::Bind(&WebMessagePortChannelImpl::PostMessage, this, | 192 FROM_HERE, base::Bind(&WebMessagePortChannelImpl::PostMessage, this, |
| 192 message, base::Passed(channels.Pass()))); | 193 message, base::Passed(std::move(channels)))); |
| 193 } else { | 194 } else { |
| 194 PostMessage(message, channels.Pass()); | 195 PostMessage(message, std::move(channels)); |
| 195 } | 196 } |
| 196 } | 197 } |
| 197 | 198 |
| 198 void WebMessagePortChannelImpl::PostMessage( | 199 void WebMessagePortChannelImpl::PostMessage( |
| 199 const MessagePortMessage& message, | 200 const MessagePortMessage& message, |
| 200 scoped_ptr<WebMessagePortChannelArray> channels) { | 201 scoped_ptr<WebMessagePortChannelArray> channels) { |
| 201 IPC::Message* msg = new MessagePortHostMsg_PostMessage( | 202 IPC::Message* msg = new MessagePortHostMsg_PostMessage( |
| 202 message_port_id_, message, ExtractMessagePortIDs(channels.Pass())); | 203 message_port_id_, message, ExtractMessagePortIDs(std::move(channels))); |
| 203 Send(msg); | 204 Send(msg); |
| 204 } | 205 } |
| 205 | 206 |
| 206 bool WebMessagePortChannelImpl::tryGetMessage( | 207 bool WebMessagePortChannelImpl::tryGetMessage( |
| 207 WebString* message, | 208 WebString* message, |
| 208 WebMessagePortChannelArray& channels) { | 209 WebMessagePortChannelArray& channels) { |
| 209 base::AutoLock auto_lock(lock_); | 210 base::AutoLock auto_lock(lock_); |
| 210 if (message_queue_.empty()) | 211 if (message_queue_.empty()) |
| 211 return false; | 212 return false; |
| 212 | 213 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 346 |
| 346 Release(); | 347 Release(); |
| 347 ChildProcess::current()->ReleaseProcess(); | 348 ChildProcess::current()->ReleaseProcess(); |
| 348 } | 349 } |
| 349 | 350 |
| 350 WebMessagePortChannelImpl::Message::Message() {} | 351 WebMessagePortChannelImpl::Message::Message() {} |
| 351 | 352 |
| 352 WebMessagePortChannelImpl::Message::~Message() {} | 353 WebMessagePortChannelImpl::Message::~Message() {} |
| 353 | 354 |
| 354 } // namespace content | 355 } // namespace content |
| OLD | NEW |