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

Side by Side Diff: extensions/renderer/messaging_bindings.cc

Issue 1951583002: Determine routing ID before potentially invalidating the frame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/renderer/messaging_bindings.h" 5 #include "extensions/renderer/messaging_bindings.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 441
442 // static 442 // static
443 void MessagingBindings::DispatchOnConnect( 443 void MessagingBindings::DispatchOnConnect(
444 const ScriptContextSet& context_set, 444 const ScriptContextSet& context_set,
445 int target_port_id, 445 int target_port_id,
446 const std::string& channel_name, 446 const std::string& channel_name,
447 const ExtensionMsg_TabConnectionInfo& source, 447 const ExtensionMsg_TabConnectionInfo& source,
448 const ExtensionMsg_ExternalConnectionInfo& info, 448 const ExtensionMsg_ExternalConnectionInfo& info,
449 const std::string& tls_channel_id, 449 const std::string& tls_channel_id,
450 content::RenderFrame* restrict_to_render_frame) { 450 content::RenderFrame* restrict_to_render_frame) {
451 int routing_id = restrict_to_render_frame
452 ? restrict_to_render_frame->GetRoutingID()
453 : MSG_ROUTING_NONE;
451 bool port_created = false; 454 bool port_created = false;
452 context_set.ForEach( 455 context_set.ForEach(
453 info.target_id, restrict_to_render_frame, 456 info.target_id, restrict_to_render_frame,
454 base::Bind(&DispatchOnConnectToScriptContext, target_port_id, 457 base::Bind(&DispatchOnConnectToScriptContext, target_port_id,
455 channel_name, &source, info, tls_channel_id, &port_created)); 458 channel_name, &source, info, tls_channel_id, &port_created));
459 // Note: |restrict_to_render_frame| may have been deleted at this point!
456 460
457 int routing_id = restrict_to_render_frame
458 ? restrict_to_render_frame->GetRoutingID()
459 : MSG_ROUTING_NONE;
460 if (port_created) { 461 if (port_created) {
461 content::RenderThread::Get()->Send( 462 content::RenderThread::Get()->Send(
462 new ExtensionHostMsg_OpenMessagePort(routing_id, target_port_id)); 463 new ExtensionHostMsg_OpenMessagePort(routing_id, target_port_id));
463 } else { 464 } else {
464 content::RenderThread::Get()->Send(new ExtensionHostMsg_CloseMessagePort( 465 content::RenderThread::Get()->Send(new ExtensionHostMsg_CloseMessagePort(
465 routing_id, target_port_id, false)); 466 routing_id, target_port_id, false));
466 } 467 }
467 } 468 }
468 469
469 // static 470 // static
(...skipping 12 matching lines...) Expand all
482 const ScriptContextSet& context_set, 483 const ScriptContextSet& context_set,
483 int port_id, 484 int port_id,
484 const std::string& error_message, 485 const std::string& error_message,
485 content::RenderFrame* restrict_to_render_frame) { 486 content::RenderFrame* restrict_to_render_frame) {
486 context_set.ForEach( 487 context_set.ForEach(
487 restrict_to_render_frame, 488 restrict_to_render_frame,
488 base::Bind(&DispatchOnDisconnectToScriptContext, port_id, error_message)); 489 base::Bind(&DispatchOnDisconnectToScriptContext, port_id, error_message));
489 } 490 }
490 491
491 } // namespace extensions 492 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698