OLD | NEW |
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 "content/renderer/pepper/message_channel.h" | 5 #include "content/renderer/pepper/message_channel.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 void MessageChannel::Start() { | 159 void MessageChannel::Start() { |
160 DCHECK_EQ(WAITING_TO_START, js_message_queue_state_); | 160 DCHECK_EQ(WAITING_TO_START, js_message_queue_state_); |
161 DCHECK_EQ(WAITING_TO_START, plugin_message_queue_state_); | 161 DCHECK_EQ(WAITING_TO_START, plugin_message_queue_state_); |
162 | 162 |
163 ppapi::proxy::HostDispatcher* dispatcher = | 163 ppapi::proxy::HostDispatcher* dispatcher = |
164 ppapi::proxy::HostDispatcher::GetForInstance(instance_->pp_instance()); | 164 ppapi::proxy::HostDispatcher::GetForInstance(instance_->pp_instance()); |
165 // The dispatcher is NULL for in-process. | 165 // The dispatcher is NULL for in-process. |
166 if (dispatcher) | 166 if (dispatcher) |
167 dispatcher->AddSyncMessageStatusObserver(this); | 167 dispatcher->AddSyncMessageStatusObserver(this); |
168 | 168 |
169 // We can't drain the JS message queue directly | 169 // We can't drain the JS message queue directly since we haven't finished |
170 // since we haven't finished initializing the PepperWebPluginImpl yet, so | 170 // initializing the PepperWebPluginImpl yet, so the plugin isn't available in |
171 // the plugin isn't available in the DOM. | 171 // the DOM. |
172 DrainJSMessageQueueSoon(); | 172 DrainJSMessageQueueSoon(); |
173 | 173 |
174 plugin_message_queue_state_ = SEND_DIRECTLY; | 174 plugin_message_queue_state_ = SEND_DIRECTLY; |
175 DrainCompletedPluginMessages(); | 175 DrainCompletedPluginMessages(); |
176 } | 176 } |
177 | 177 |
178 void MessageChannel::SetPassthroughObject(v8::Handle<v8::Object> passthrough) { | 178 void MessageChannel::SetPassthroughObject(v8::Handle<v8::Object> passthrough) { |
179 passthrough_object_.Reset(instance_->GetIsolate(), passthrough); | 179 passthrough_object_.Reset(instance_->GetIsolate(), passthrough); |
180 } | 180 } |
181 | 181 |
(...skipping 20 matching lines...) Expand all Loading... |
202 return Wrappable<MessageChannel>::GetObjectTemplateBuilder(isolate) | 202 return Wrappable<MessageChannel>::GetObjectTemplateBuilder(isolate) |
203 .AddNamedPropertyInterceptor(); | 203 .AddNamedPropertyInterceptor(); |
204 } | 204 } |
205 | 205 |
206 void MessageChannel::BeginBlockOnSyncMessage() { | 206 void MessageChannel::BeginBlockOnSyncMessage() { |
207 js_message_queue_state_ = QUEUE_MESSAGES; | 207 js_message_queue_state_ = QUEUE_MESSAGES; |
208 ++blocking_message_depth_; | 208 ++blocking_message_depth_; |
209 } | 209 } |
210 | 210 |
211 void MessageChannel::EndBlockOnSyncMessage() { | 211 void MessageChannel::EndBlockOnSyncMessage() { |
| 212 DCHECK_GT(blocking_message_depth_, 0); |
212 --blocking_message_depth_; | 213 --blocking_message_depth_; |
213 if (!blocking_message_depth_) | 214 if (!blocking_message_depth_) |
214 DrainJSMessageQueueSoon(); | 215 DrainJSMessageQueueSoon(); |
215 } | 216 } |
216 | 217 |
217 v8::Local<v8::Value> MessageChannel::GetNamedProperty( | 218 v8::Local<v8::Value> MessageChannel::GetNamedProperty( |
218 v8::Isolate* isolate, | 219 v8::Isolate* isolate, |
219 const std::string& identifier) { | 220 const std::string& identifier) { |
220 if (!instance_) | 221 if (!instance_) |
221 return v8::Local<v8::Value>(); | 222 return v8::Local<v8::Value>(); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 } | 464 } |
464 | 465 |
465 void MessageChannel::DrainJSMessageQueueSoon() { | 466 void MessageChannel::DrainJSMessageQueueSoon() { |
466 base::MessageLoop::current()->PostTask( | 467 base::MessageLoop::current()->PostTask( |
467 FROM_HERE, | 468 FROM_HERE, |
468 base::Bind(&MessageChannel::DrainJSMessageQueue, | 469 base::Bind(&MessageChannel::DrainJSMessageQueue, |
469 weak_ptr_factory_.GetWeakPtr())); | 470 weak_ptr_factory_.GetWeakPtr())); |
470 } | 471 } |
471 | 472 |
472 } // namespace content | 473 } // namespace content |
OLD | NEW |