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

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

Issue 1931253004: Determine routing ID before potentially invalidating the frame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment 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 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 442
443 // static 443 // static
444 void MessagingBindings::DispatchOnConnect( 444 void MessagingBindings::DispatchOnConnect(
445 const ScriptContextSet& context_set, 445 const ScriptContextSet& context_set,
446 int target_port_id, 446 int target_port_id,
447 const std::string& channel_name, 447 const std::string& channel_name,
448 const ExtensionMsg_TabConnectionInfo& source, 448 const ExtensionMsg_TabConnectionInfo& source,
449 const ExtensionMsg_ExternalConnectionInfo& info, 449 const ExtensionMsg_ExternalConnectionInfo& info,
450 const std::string& tls_channel_id, 450 const std::string& tls_channel_id,
451 content::RenderFrame* restrict_to_render_frame) { 451 content::RenderFrame* restrict_to_render_frame) {
452 int routing_id = restrict_to_render_frame
453 ? restrict_to_render_frame->GetRoutingID()
454 : MSG_ROUTING_NONE;
452 bool port_created = false; 455 bool port_created = false;
453 context_set.ForEach( 456 context_set.ForEach(
454 info.target_id, restrict_to_render_frame, 457 info.target_id, restrict_to_render_frame,
455 base::Bind(&DispatchOnConnectToScriptContext, target_port_id, 458 base::Bind(&DispatchOnConnectToScriptContext, target_port_id,
456 channel_name, &source, info, tls_channel_id, &port_created)); 459 channel_name, &source, info, tls_channel_id, &port_created));
460 // Note: |restrict_to_render_frame| may have been deleted at this point!
457 461
458 int routing_id = restrict_to_render_frame
459 ? restrict_to_render_frame->GetRoutingID()
460 : MSG_ROUTING_NONE;
461 if (port_created) { 462 if (port_created) {
462 content::RenderThread::Get()->Send( 463 content::RenderThread::Get()->Send(
463 new ExtensionHostMsg_OpenMessagePort(routing_id, target_port_id)); 464 new ExtensionHostMsg_OpenMessagePort(routing_id, target_port_id));
464 } else { 465 } else {
465 content::RenderThread::Get()->Send(new ExtensionHostMsg_CloseMessagePort( 466 content::RenderThread::Get()->Send(new ExtensionHostMsg_CloseMessagePort(
466 routing_id, target_port_id, false)); 467 routing_id, target_port_id, false));
467 } 468 }
468 } 469 }
469 470
470 // static 471 // static
(...skipping 12 matching lines...) Expand all
483 const ScriptContextSet& context_set, 484 const ScriptContextSet& context_set,
484 int port_id, 485 int port_id,
485 const std::string& error_message, 486 const std::string& error_message,
486 content::RenderFrame* restrict_to_render_frame) { 487 content::RenderFrame* restrict_to_render_frame) {
487 context_set.ForEach( 488 context_set.ForEach(
488 restrict_to_render_frame, 489 restrict_to_render_frame,
489 base::Bind(&DispatchOnDisconnectToScriptContext, port_id, error_message)); 490 base::Bind(&DispatchOnDisconnectToScriptContext, port_id, error_message));
490 } 491 }
491 492
492 } // namespace extensions 493 } // 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