Update broken references to image assets
[chromium-blink-merge.git] / extensions / browser / mojo / keep_alive_impl.h
blobdf365f33da2611173cd7176100900a6e7ccddba3
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 "base/scoped_observer.h"
10 #include "extensions/browser/extension_registry_observer.h"
11 #include "extensions/common/mojo/keep_alive.mojom.h"
12 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
13 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
15 namespace content {
16 class BrowserContext;
19 namespace extensions {
20 class Extension;
22 // An RAII mojo service implementation for extension keep alives. This adds a
23 // keep alive on construction and removes it on destruction.
24 class KeepAliveImpl : public KeepAlive, public ExtensionRegistryObserver {
25 public:
26 // Create a keep alive for |extension| running in |context| and connect it to
27 // |request|. When the requester closes its pipe, the keep alive ends.
28 static void Create(content::BrowserContext* context,
29 const Extension* extension,
30 mojo::InterfaceRequest<KeepAlive> request);
32 private:
33 KeepAliveImpl(content::BrowserContext* context,
34 const Extension* extension,
35 mojo::InterfaceRequest<KeepAlive> request);
36 ~KeepAliveImpl() override;
38 // ExtensionRegistryObserver overrides.
39 void OnExtensionUnloaded(content::BrowserContext* browser_context,
40 const Extension* extension,
41 UnloadedExtensionInfo::Reason reason) override;
42 void OnShutdown(ExtensionRegistry* registry) override;
44 // Invoked when the mojo connection is disconnected.
45 void OnDisconnected();
47 content::BrowserContext* context_;
48 const Extension* extension_;
49 ScopedObserver<ExtensionRegistry, KeepAliveImpl> extension_registry_observer_;
50 mojo::StrongBinding<KeepAlive> binding_;
52 DISALLOW_COPY_AND_ASSIGN(KeepAliveImpl);
55 } // namespace extensions
57 #endif // EXTENSIONS_BROWSER_MOJO_KEEP_ALIVE_IMPL_H_