| 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(host->extension()); | 145 pm->IncrementLazyKeepaliveCount(host->extension(), true); |
| 146 | 146 |
| 147 // 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 |
| 148 // the host hasn't reloaded. | 148 // the host hasn't reloaded. |
| 149 port->background_host_ptr = host; | 149 port->background_host_ptr = host; |
| 150 } | 150 } |
| 151 | 151 |
| 152 static void DecrementLazyKeepaliveCount( | 152 static void DecrementLazyKeepaliveCount( |
| 153 ExtensionMessageService::MessagePort* port) { | 153 ExtensionMessageService::MessagePort* port) { |
| 154 Profile* profile = | 154 Profile* profile = |
| 155 Profile::FromBrowserContext(port->process->GetBrowserContext()); | 155 Profile::FromBrowserContext(port->process->GetBrowserContext()); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 OpenChannelParams params = params_in; | 463 OpenChannelParams params = params_in; |
| 464 params.source = content::RenderProcessHost::FromID(source_process_id); | 464 params.source = content::RenderProcessHost::FromID(source_process_id); |
| 465 if (!params.source) | 465 if (!params.source) |
| 466 return; | 466 return; |
| 467 | 467 |
| 468 params.receiver = MessagePort(host->render_process_host(), | 468 params.receiver = MessagePort(host->render_process_host(), |
| 469 MSG_ROUTING_CONTROL, | 469 MSG_ROUTING_CONTROL, |
| 470 params.target_extension_id); | 470 params.target_extension_id); |
| 471 OpenChannelImpl(params); | 471 OpenChannelImpl(params); |
| 472 } | 472 } |
| OLD | NEW |