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

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

Issue 1966283002: Remove port lifetime management from renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use MakeUnique instead of WrapUnique 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
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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 params->source_routing_id); 562 params->source_routing_id);
563 if (!source) 563 if (!source)
564 return; // Closed while in flight. 564 return; // Closed while in flight.
565 565
566 if (!params->receiver || !params->receiver->IsValidPort()) { 566 if (!params->receiver || !params->receiver->IsValidPort()) {
567 DispatchOnDisconnect(source, params->receiver_port_id, 567 DispatchOnDisconnect(source, params->receiver_port_id,
568 kReceivingEndDoesntExistError); 568 kReceivingEndDoesntExistError);
569 return; 569 return;
570 } 570 }
571 571
572 std::unique_ptr<MessagePort> opener( 572 std::unique_ptr<ExtensionMessagePort> opener(
573 new ExtensionMessagePort(weak_factory_.GetWeakPtr(), 573 new ExtensionMessagePort(weak_factory_.GetWeakPtr(),
574 GET_OPPOSITE_PORT_ID(params->receiver_port_id), 574 GET_OPPOSITE_PORT_ID(params->receiver_port_id),
575 params->source_extension_id, source, false)); 575 params->source_extension_id, source, false));
576 if (!opener->IsValidPort()) 576 if (!opener->IsValidPort())
577 return; 577 return;
578 opener->OpenPort(params->source_process_id, params->source_routing_id); 578 opener->OpenPort(params->source_process_id, params->source_routing_id);
579 opener->RevalidatePort();
579 580
580 params->receiver->RemoveCommonFrames(*opener); 581 params->receiver->RemoveCommonFrames(*opener);
581 if (!params->receiver->IsValidPort()) { 582 if (!params->receiver->IsValidPort()) {
582 opener->DispatchOnDisconnect(kReceivingEndDoesntExistError); 583 opener->DispatchOnDisconnect(kReceivingEndDoesntExistError);
583 return; 584 return;
584 } 585 }
585 586
586 MessageChannel* channel(new MessageChannel()); 587 MessageChannel* channel(new MessageChannel());
587 channel->opener.reset(opener.release()); 588 channel->opener.reset(opener.release());
588 channel->receiver.reset(params->receiver.release()); 589 channel->receiver.reset(params->receiver.release());
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 1011
1011 MessageChannelMap::iterator channel_iter = channels_.find(channel_id); 1012 MessageChannelMap::iterator channel_iter = channels_.find(channel_id);
1012 if (channel_iter != channels_.end()) { 1013 if (channel_iter != channels_.end()) {
1013 for (const PendingMessage& message : queue) { 1014 for (const PendingMessage& message : queue) {
1014 DispatchMessage(message.first, channel_iter->second, message.second); 1015 DispatchMessage(message.first, channel_iter->second, message.second);
1015 } 1016 }
1016 } 1017 }
1017 } 1018 }
1018 1019
1019 } // namespace extensions 1020 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/messaging/extension_message_port.cc ('k') | extensions/common/extension_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698