Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / extensions / browser / mojo / keep_alive_impl.h
blob09473e27bcd2d3f6b5f255d4f4646002be2a438a
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"
12 namespace content {
13 class BrowserContext;
16 namespace extensions {
17 class Extension;
19 // An RAII mojo service implementation for extension keep alives. This adds a
20 // keep alive on construction and removes it on destruction.
21 class KeepAliveImpl : public mojo::InterfaceImpl<KeepAlive> {
22 public:
23 // Create a keep alive for |extension| running in |context| and connect it to
24 // |request|. When the requester closes its pipe, the keep alive ends.
25 static void Create(content::BrowserContext* context,
26 const Extension* extension,
27 mojo::InterfaceRequest<KeepAlive> request);
29 private:
30 KeepAliveImpl(content::BrowserContext* context, const Extension* extension);
31 ~KeepAliveImpl() override;
33 content::BrowserContext* context_;
34 const Extension* extension_;
36 DISALLOW_COPY_AND_ASSIGN(KeepAliveImpl);
39 } // namespace extensions
41 #endif // EXTENSIONS_BROWSER_MOJO_KEEP_ALIVE_IMPL_H_