OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 MOJO_SHELL_CONTENT_HANDLER_CONNECTION_H_ | 5 #ifndef MOJO_PACKAGE_MANAGER_CONTENT_HANDLER_CONNECTION_H_ |
6 #define MOJO_SHELL_CONTENT_HANDLER_CONNECTION_H_ | 6 #define MOJO_PACKAGE_MANAGER_CONTENT_HANDLER_CONNECTION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
| 10 #include "base/callback.h" |
10 #include "mojo/application/public/interfaces/content_handler.mojom.h" | 11 #include "mojo/application/public/interfaces/content_handler.mojom.h" |
11 #include "mojo/shell/identity.h" | 12 #include "mojo/shell/identity.h" |
12 #include "url/gurl.h" | 13 #include "url/gurl.h" |
13 | 14 |
14 namespace mojo { | 15 namespace mojo { |
15 namespace shell { | 16 namespace shell { |
16 | |
17 class ApplicationManager; | 17 class ApplicationManager; |
18 class Identity; | 18 } |
| 19 namespace package_manager { |
19 | 20 |
20 // A ContentHandlerConnection is responsible for creating and maintaining a | 21 // A ContentHandlerConnection is responsible for creating and maintaining a |
21 // connection to an app which provides the ContentHandler service. | 22 // connection to an app which provides the ContentHandler service. |
22 // A ContentHandlerConnection can only be destroyed via CloseConnection. | 23 // A ContentHandlerConnection can only be destroyed via CloseConnection. |
23 // A ContentHandlerConnection manages its own lifetime and cannot be used with | 24 // A ContentHandlerConnection manages its own lifetime and cannot be used with |
24 // a scoped_ptr to avoid reentrant calls into ApplicationManager late in | 25 // a scoped_ptr to avoid reentrant calls into ApplicationManager late in |
25 // destruction. | 26 // destruction. |
26 class ContentHandlerConnection { | 27 class ContentHandlerConnection { |
27 public: | 28 public: |
| 29 using ClosedCallback = base::Callback<void(ContentHandlerConnection*)>; |
28 // |id| is a unique identifier for this content handler. | 30 // |id| is a unique identifier for this content handler. |
29 ContentHandlerConnection(ApplicationManager* manager, | 31 ContentHandlerConnection(shell::ApplicationManager* manager, |
30 const Identity& source, | 32 const shell::Identity& source, |
31 const Identity& content_handler, | 33 const shell::Identity& content_handler, |
32 uint32_t id); | 34 uint32_t id, |
| 35 const ClosedCallback& connection_closed_callback); |
33 | 36 |
34 // Closes the connection and destroys |this| object. | 37 // Closes the connection and destroys |this| object. |
35 void CloseConnection(); | 38 void CloseConnection(); |
36 | 39 |
37 ContentHandler* content_handler() { return content_handler_.get(); } | 40 ContentHandler* content_handler() { return content_handler_.get(); } |
38 const Identity& identity() const { return identity_; } | 41 const shell::Identity& identity() const { return identity_; } |
39 uint32_t id() const { return id_; } | 42 uint32_t id() const { return id_; } |
40 | 43 |
41 private: | 44 private: |
42 ~ContentHandlerConnection(); | 45 ~ContentHandlerConnection(); |
43 | 46 |
44 ApplicationManager* manager_; | 47 ClosedCallback connection_closed_callback_; |
45 Identity identity_; | 48 shell::Identity identity_; |
| 49 |
46 ContentHandlerPtr content_handler_; | 50 ContentHandlerPtr content_handler_; |
47 bool connection_closed_; | 51 bool connection_closed_; |
48 // The id for this content handler. | 52 // The id for this content handler. |
49 const uint32_t id_; | 53 const uint32_t id_; |
50 | 54 |
51 DISALLOW_COPY_AND_ASSIGN(ContentHandlerConnection); | 55 DISALLOW_COPY_AND_ASSIGN(ContentHandlerConnection); |
52 }; | 56 }; |
53 | 57 |
54 } // namespace shell | 58 } // namespace package_manager |
55 } // namespace mojo | 59 } // namespace mojo |
56 | 60 |
57 #endif // MOJO_SHELL_CONTENT_HANDLER_CONNECTION_H_ | 61 #endif // MOJO_PACKAGE_MANAGER_CONTENT_HANDLER_CONNECTION_H_ |
OLD | NEW |