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

Side by Side Diff: chrome/browser/extensions/api/messaging/message_service.cc

Issue 1625993002: Mark opener extension port as opened after creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | chrome/test/data/extensions/api_test/messaging/connect/page.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdint.h> 7 #include <stdint.h>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 return; 442 return;
443 } 443 }
444 444
445 scoped_ptr<MessageChannel> channel(new MessageChannel()); 445 scoped_ptr<MessageChannel> channel(new MessageChannel());
446 channel->opener.reset( 446 channel->opener.reset(
447 new ExtensionMessagePort(weak_factory_.GetWeakPtr(), 447 new ExtensionMessagePort(weak_factory_.GetWeakPtr(),
448 GET_OPPOSITE_PORT_ID(receiver_port_id), 448 GET_OPPOSITE_PORT_ID(receiver_port_id),
449 source_extension_id, source, false)); 449 source_extension_id, source, false));
450 if (!channel->opener->IsValidPort()) 450 if (!channel->opener->IsValidPort())
451 return; 451 return;
452 channel->opener->OpenPort(source_process_id, source_routing_id);
452 453
453 // Get handle of the native view and pass it to the native messaging host. 454 // Get handle of the native view and pass it to the native messaging host.
454 gfx::NativeView native_view = source ? source->GetNativeView() : nullptr; 455 gfx::NativeView native_view = source ? source->GetNativeView() : nullptr;
455 456
456 std::string error = kReceivingEndDoesntExistError; 457 std::string error = kReceivingEndDoesntExistError;
457 scoped_ptr<NativeMessageHost> native_host = NativeMessageHost::Create( 458 scoped_ptr<NativeMessageHost> native_host = NativeMessageHost::Create(
458 native_view, 459 native_view,
459 source_extension_id, 460 source_extension_id,
460 native_app_name, 461 native_app_name,
461 policy_permission == ALLOW_ALL, 462 policy_permission == ALLOW_ALL,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 kReceivingEndDoesntExistError); 569 kReceivingEndDoesntExistError);
569 return; 570 return;
570 } 571 }
571 572
572 scoped_ptr<MessagePort> opener( 573 scoped_ptr<MessagePort> opener(
573 new ExtensionMessagePort(weak_factory_.GetWeakPtr(), 574 new ExtensionMessagePort(weak_factory_.GetWeakPtr(),
574 GET_OPPOSITE_PORT_ID(params->receiver_port_id), 575 GET_OPPOSITE_PORT_ID(params->receiver_port_id),
575 params->source_extension_id, source, false)); 576 params->source_extension_id, source, false));
576 if (!opener->IsValidPort()) 577 if (!opener->IsValidPort())
577 return; 578 return;
579 opener->OpenPort(params->source_process_id, params->source_routing_id);
578 580
579 params->receiver->RemoveCommonFrames(*opener); 581 params->receiver->RemoveCommonFrames(*opener);
580 if (!params->receiver->IsValidPort()) { 582 if (!params->receiver->IsValidPort()) {
581 opener->DispatchOnDisconnect(kReceivingEndDoesntExistError); 583 opener->DispatchOnDisconnect(kReceivingEndDoesntExistError);
582 return; 584 return;
583 } 585 }
584 586
585 MessageChannel* channel(new MessageChannel()); 587 MessageChannel* channel(new MessageChannel());
586 channel->opener.reset(opener.release()); 588 channel->opener.reset(opener.release());
587 channel->receiver.reset(params->receiver.release()); 589 channel->receiver.reset(params->receiver.release());
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 1010
1009 MessageChannelMap::iterator channel_iter = channels_.find(channel_id); 1011 MessageChannelMap::iterator channel_iter = channels_.find(channel_id);
1010 if (channel_iter != channels_.end()) { 1012 if (channel_iter != channels_.end()) {
1011 for (const PendingMessage& message : queue) { 1013 for (const PendingMessage& message : queue) {
1012 DispatchMessage(message.first, channel_iter->second, message.second); 1014 DispatchMessage(message.first, channel_iter->second, message.second);
1013 } 1015 }
1014 } 1016 }
1015 } 1017 }
1016 1018
1017 } // namespace extensions 1019 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/messaging/connect/page.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698