OLD | NEW |
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/extension_message_service.h" | 5 #include "chrome/browser/extensions/extension_message_service.h" |
6 | 6 |
7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 135 } |
136 | 136 |
137 static void IncrementLazyKeepaliveCount( | 137 static void IncrementLazyKeepaliveCount( |
138 ExtensionMessageService::MessagePort* port) { | 138 ExtensionMessageService::MessagePort* port) { |
139 Profile* profile = | 139 Profile* profile = |
140 Profile::FromBrowserContext(port->process->GetBrowserContext()); | 140 Profile::FromBrowserContext(port->process->GetBrowserContext()); |
141 ExtensionProcessManager* pm = | 141 ExtensionProcessManager* pm = |
142 extensions::ExtensionSystem::Get(profile)->process_manager(); | 142 extensions::ExtensionSystem::Get(profile)->process_manager(); |
143 ExtensionHost* host = pm->GetBackgroundHostForExtension(port->extension_id); | 143 ExtensionHost* host = pm->GetBackgroundHostForExtension(port->extension_id); |
144 if (host && host->extension()->has_lazy_background_page()) | 144 if (host && host->extension()->has_lazy_background_page()) |
145 pm->IncrementLazyKeepaliveCount( | 145 pm->IncrementLazyKeepaliveCount(host->extension()); |
146 host->extension(), ExtensionProcessManager::CANCEL_SUSPEND); | |
147 | 146 |
148 // Keep track of the background host, so when we decrement, we only do so if | 147 // Keep track of the background host, so when we decrement, we only do so if |
149 // the host hasn't reloaded. | 148 // the host hasn't reloaded. |
150 port->background_host_ptr = host; | 149 port->background_host_ptr = host; |
151 } | 150 } |
152 | 151 |
153 static void DecrementLazyKeepaliveCount( | 152 static void DecrementLazyKeepaliveCount( |
154 ExtensionMessageService::MessagePort* port) { | 153 ExtensionMessageService::MessagePort* port) { |
155 Profile* profile = | 154 Profile* profile = |
156 Profile::FromBrowserContext(port->process->GetBrowserContext()); | 155 Profile::FromBrowserContext(port->process->GetBrowserContext()); |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 OpenChannelParams params = params_in; | 463 OpenChannelParams params = params_in; |
465 params.source = content::RenderProcessHost::FromID(source_process_id); | 464 params.source = content::RenderProcessHost::FromID(source_process_id); |
466 if (!params.source) | 465 if (!params.source) |
467 return; | 466 return; |
468 | 467 |
469 params.receiver = MessagePort(host->render_process_host(), | 468 params.receiver = MessagePort(host->render_process_host(), |
470 MSG_ROUTING_CONTROL, | 469 MSG_ROUTING_CONTROL, |
471 params.target_extension_id); | 470 params.target_extension_id); |
472 OpenChannelImpl(params); | 471 OpenChannelImpl(params); |
473 } | 472 } |
OLD | NEW |