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 "chrome/browser/extensions/api/messaging/message_service.h" | 5 #include "chrome/browser/extensions/api/messaging/message_service.h" |
6 | 6 |
7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 channel_name, | 323 channel_name, |
324 include_tls_channel_id); | 324 include_tls_channel_id); |
325 | 325 |
326 // If the target requests the TLS channel id, begin the lookup for it. | 326 // If the target requests the TLS channel id, begin the lookup for it. |
327 // The target might also be a lazy background page, checked next, but the | 327 // The target might also be a lazy background page, checked next, but the |
328 // loading of lazy background pages continues asynchronously, so enqueue | 328 // loading of lazy background pages continues asynchronously, so enqueue |
329 // messages awaiting TLS channel ID first. | 329 // messages awaiting TLS channel ID first. |
330 if (include_tls_channel_id) { | 330 if (include_tls_channel_id) { |
331 pending_tls_channel_id_channels_[GET_CHANNEL_ID(params->receiver_port_id)] | 331 pending_tls_channel_id_channels_[GET_CHANNEL_ID(params->receiver_port_id)] |
332 = PendingMessagesQueue(); | 332 = PendingMessagesQueue(); |
333 property_provider_.GetDomainBoundCert( | 333 property_provider_.GetChannelID( |
334 Profile::FromBrowserContext(context), | 334 Profile::FromBrowserContext(context), |
335 source_url, | 335 source_url, |
336 base::Bind(&MessageService::GotDomainBoundCert, | 336 base::Bind(&MessageService::GotChannelID, |
337 weak_factory_.GetWeakPtr(), | 337 weak_factory_.GetWeakPtr(), |
338 base::Passed(make_scoped_ptr(params)))); | 338 base::Passed(make_scoped_ptr(params)))); |
339 return; | 339 return; |
340 } | 340 } |
341 | 341 |
342 // The target might be a lazy background page. In that case, we have to check | 342 // The target might be a lazy background page. In that case, we have to check |
343 // if it is loaded and ready, and if not, queue up the task and load the | 343 // if it is loaded and ready, and if not, queue up the task and load the |
344 // page. | 344 // page. |
345 if (MaybeAddPendingLazyBackgroundPageOpenChannelTask( | 345 if (MaybeAddPendingLazyBackgroundPageOpenChannelTask( |
346 context, target_extension, params)) { | 346 context, target_extension, params)) { |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 lazy_background_task_queue_->AddPendingTask( | 686 lazy_background_task_queue_->AddPendingTask( |
687 context, | 687 context, |
688 extension->id(), | 688 extension->id(), |
689 base::Bind(&MessageService::PendingLazyBackgroundPageOpenChannel, | 689 base::Bind(&MessageService::PendingLazyBackgroundPageOpenChannel, |
690 weak_factory_.GetWeakPtr(), | 690 weak_factory_.GetWeakPtr(), |
691 base::Passed(&scoped_params), | 691 base::Passed(&scoped_params), |
692 params->source->GetID())); | 692 params->source->GetID())); |
693 return true; | 693 return true; |
694 } | 694 } |
695 | 695 |
696 void MessageService::GotDomainBoundCert(scoped_ptr<OpenChannelParams> params, | 696 void MessageService::GotChannelID(scoped_ptr<OpenChannelParams> params, |
697 const std::string& tls_channel_id) { | 697 const std::string& tls_channel_id) { |
698 params->tls_channel_id.assign(tls_channel_id); | 698 params->tls_channel_id.assign(tls_channel_id); |
699 int channel_id = GET_CHANNEL_ID(params->receiver_port_id); | 699 int channel_id = GET_CHANNEL_ID(params->receiver_port_id); |
700 | 700 |
701 PendingTlsChannelIdMap::iterator pending_for_tls_channel_id = | 701 PendingTlsChannelIdMap::iterator pending_for_tls_channel_id = |
702 pending_tls_channel_id_channels_.find(channel_id); | 702 pending_tls_channel_id_channels_.find(channel_id); |
703 if (pending_for_tls_channel_id == pending_tls_channel_id_channels_.end()) { | 703 if (pending_for_tls_channel_id == pending_tls_channel_id_channels_.end()) { |
704 NOTREACHED(); | 704 NOTREACHED(); |
705 return; | 705 return; |
706 } | 706 } |
707 | 707 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 } | 766 } |
767 | 767 |
768 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source, | 768 void MessageService::DispatchOnDisconnect(content::RenderProcessHost* source, |
769 int port_id, | 769 int port_id, |
770 const std::string& error_message) { | 770 const std::string& error_message) { |
771 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, ""); | 771 ExtensionMessagePort port(source, MSG_ROUTING_CONTROL, ""); |
772 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message); | 772 port.DispatchOnDisconnect(GET_OPPOSITE_PORT_ID(port_id), error_message); |
773 } | 773 } |
774 | 774 |
775 } // namespace extensions | 775 } // namespace extensions |
OLD | NEW |