Commit 214c72d7 authored by Istiaque Ahmed's avatar Istiaque Ahmed Committed by Commit Bot

Extension MessageService: Clean up code for LazyContextId.

Do not create new LazyContextIds when existing ones can be used.

Bug: None
Test: No visible side-effect expected.
Change-Id: Id8837392f74e07efa1efa200fd87789cddc866e3
Reviewed-on: https://chromium-review.googlesource.com/c/1487204
Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635896}
parent 4e094bff
......@@ -636,8 +636,7 @@ void MessageService::ClosePortImpl(const PortId& port_id,
if (it == channels_.end()) {
auto pending = pending_lazy_background_page_channels_.find(channel_id);
if (pending != pending_lazy_background_page_channels_.end()) {
const LazyContextId context_id(pending->second.browser_context(),
pending->second.extension_id());
const LazyContextId& context_id = pending->second;
context_id.GetTaskQueue()->AddPendingTask(
context_id,
base::BindOnce(&MessageService::PendingLazyBackgroundPageClosePort,
......@@ -726,8 +725,7 @@ void MessageService::EnqueuePendingMessageForLazyBackgroundLoad(
auto pending = pending_lazy_background_page_channels_.find(channel_id);
if (pending != pending_lazy_background_page_channels_.end()) {
const LazyContextId context_id(pending->second.browser_context(),
pending->second.extension_id());
const LazyContextId& context_id = pending->second;
context_id.GetTaskQueue()->AddPendingTask(
context_id,
base::BindOnce(&MessageService::PendingLazyBackgroundPagePostMessage,
......@@ -770,8 +768,7 @@ bool MessageService::MaybeAddPendingLazyBackgroundPageOpenChannelTask(
return false;
ChannelId channel_id = (*params)->receiver_port_id.GetChannelId();
pending_lazy_background_page_channels_.insert(std::make_pair(
channel_id, PendingLazyBackgroundPageChannel(context, extension->id())));
pending_lazy_background_page_channels_.emplace(channel_id, context_id);
int source_id = (*params)->source_process_id;
task_queue->AddPendingTask(
context_id,
......
......@@ -137,9 +137,8 @@ class MessageService : public BrowserContextKeyedAPI,
// A map of channel ID to information about the extension that is waiting
// for that channel to open. Used for lazy background pages.
using PendingLazyBackgroundPageChannel = LazyContextId;
using PendingLazyBackgroundPageChannelMap =
std::map<ChannelId, PendingLazyBackgroundPageChannel>;
std::map<ChannelId, LazyContextId>;
// Common implementation for opening a channel configured by |params|.
//
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment