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