| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/mojo/keep_alive_impl.h" | 5 #include "extensions/browser/mojo/keep_alive_impl.h" |
| 6 | 6 |
| 7 #include "extensions/browser/extension_system.h" | |
| 8 #include "extensions/browser/process_manager.h" | 7 #include "extensions/browser/process_manager.h" |
| 9 | 8 |
| 10 namespace extensions { | 9 namespace extensions { |
| 11 | 10 |
| 12 // static | 11 // static |
| 13 void KeepAliveImpl::Create(content::BrowserContext* context, | 12 void KeepAliveImpl::Create(content::BrowserContext* context, |
| 14 const Extension* extension, | 13 const Extension* extension, |
| 15 mojo::InterfaceRequest<KeepAlive> request) { | 14 mojo::InterfaceRequest<KeepAlive> request) { |
| 16 mojo::BindToRequest(new KeepAliveImpl(context, extension), &request); | 15 mojo::BindToRequest(new KeepAliveImpl(context, extension), &request); |
| 17 } | 16 } |
| 18 | 17 |
| 19 KeepAliveImpl::KeepAliveImpl(content::BrowserContext* context, | 18 KeepAliveImpl::KeepAliveImpl(content::BrowserContext* context, |
| 20 const Extension* extension) | 19 const Extension* extension) |
| 21 : context_(context), extension_(extension) { | 20 : context_(context), extension_(extension) { |
| 22 ExtensionSystem* system = ExtensionSystem::Get(context_); | 21 ProcessManager::Get(context_)->IncrementLazyKeepaliveCount(extension_); |
| 23 if (!system) | |
| 24 return; | |
| 25 system->process_manager()->IncrementLazyKeepaliveCount(extension_); | |
| 26 } | 22 } |
| 27 | 23 |
| 28 KeepAliveImpl::~KeepAliveImpl() { | 24 KeepAliveImpl::~KeepAliveImpl() { |
| 29 ExtensionSystem* system = ExtensionSystem::Get(context_); | 25 ProcessManager::Get(context_)->DecrementLazyKeepaliveCount(extension_); |
| 30 if (!system) | |
| 31 return; | |
| 32 system->process_manager()->DecrementLazyKeepaliveCount(extension_); | |
| 33 } | 26 } |
| 34 | 27 |
| 35 } // namespace extensions | 28 } // namespace extensions |
| OLD | NEW |