OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MOJO_SHELL_SHELL_CLIENT_FACTORY_CONNECTION_H_ |
| 6 #define MOJO_SHELL_SHELL_CLIENT_FACTORY_CONNECTION_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include <string> |
| 11 |
| 12 #include "base/callback.h" |
| 13 #include "base/macros.h" |
| 14 #include "mojo/shell/identity.h" |
| 15 #include "mojo/shell/public/interfaces/shell_client_factory.mojom.h" |
| 16 #include "url/gurl.h" |
| 17 |
| 18 namespace mojo { |
| 19 namespace shell { |
| 20 class ApplicationManager; |
| 21 |
| 22 // A ShellClientFactoryConnection is responsible for creating and maintaining a |
| 23 // connection to an app which provides the ShellClientFactory service. |
| 24 // A ShellClientFactoryConnection can only be destroyed via CloseConnection. |
| 25 // A ShellClientFactoryConnection manages its own lifetime and cannot be used |
| 26 // with a scoped_ptr to avoid reentrant calls into ApplicationManager late in |
| 27 // destruction. |
| 28 class ShellClientFactoryConnection { |
| 29 public: |
| 30 using ClosedCallback = base::Callback<void(ShellClientFactoryConnection*)>; |
| 31 // |id| is a unique identifier for this content handler. |
| 32 ShellClientFactoryConnection(ApplicationManager* manager, |
| 33 const Identity& source, |
| 34 const Identity& shell_client_factory, |
| 35 uint32_t id, |
| 36 const ClosedCallback& connection_closed_callback); |
| 37 |
| 38 void CreateShellClient(mojom::ShellClientRequest request, const GURL& url); |
| 39 |
| 40 // Closes the connection and destroys |this| object. |
| 41 void CloseConnection(); |
| 42 |
| 43 const Identity& identity() const { return identity_; } |
| 44 uint32_t id() const { return id_; } |
| 45 |
| 46 private: |
| 47 ~ShellClientFactoryConnection(); |
| 48 |
| 49 void ApplicationDestructed(); |
| 50 |
| 51 ClosedCallback connection_closed_callback_; |
| 52 Identity identity_; |
| 53 |
| 54 mojom::ShellClientFactoryPtr shell_client_factory_; |
| 55 bool connection_closed_; |
| 56 // The id for this content handler. |
| 57 const uint32_t id_; |
| 58 int ref_count_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(ShellClientFactoryConnection); |
| 61 }; |
| 62 |
| 63 } // namespace shell |
| 64 } // namespace mojo |
| 65 |
| 66 #endif // MOJO_SHELL_SHELL_CLIENT_FACTORY_CONNECTION_H_ |
OLD | NEW |