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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_BROWSER_MOJO_KEEP_ALIVE_IMPL_H_
6 #define EXTENSIONS_BROWSER_MOJO_KEEP_ALIVE_IMPL_H_
8 #include "base/callback.h"
9 #include "extensions/common/mojo/keep_alive.mojom.h"
10 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
11 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
17 namespace extensions
{
20 // An RAII mojo service implementation for extension keep alives. This adds a
21 // keep alive on construction and removes it on destruction.
22 class KeepAliveImpl
: public KeepAlive
{
24 // Create a keep alive for |extension| running in |context| and connect it to
25 // |request|. When the requester closes its pipe, the keep alive ends.
26 static void Create(content::BrowserContext
* context
,
27 const Extension
* extension
,
28 mojo::InterfaceRequest
<KeepAlive
> request
);
31 KeepAliveImpl(content::BrowserContext
* context
,
32 const Extension
* extension
,
33 mojo::InterfaceRequest
<KeepAlive
> request
);
34 ~KeepAliveImpl() override
;
36 content::BrowserContext
* context_
;
37 const Extension
* extension_
;
38 mojo::StrongBinding
<KeepAlive
> binding_
;
40 DISALLOW_COPY_AND_ASSIGN(KeepAliveImpl
);
43 } // namespace extensions
45 #endif // EXTENSIONS_BROWSER_MOJO_KEEP_ALIVE_IMPL_H_