| 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_PACKAGE_MANAGER_CONTENT_HANDLER_CONNECTION_H_ | |
| 6 #define MOJO_PACKAGE_MANAGER_CONTENT_HANDLER_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/application/public/interfaces/content_handler.mojom.h" | |
| 15 #include "mojo/shell/identity.h" | |
| 16 #include "url/gurl.h" | |
| 17 | |
| 18 namespace mojo { | |
| 19 namespace shell { | |
| 20 class ApplicationManager; | |
| 21 } | |
| 22 namespace package_manager { | |
| 23 | |
| 24 // A ContentHandlerConnection is responsible for creating and maintaining a | |
| 25 // connection to an app which provides the ContentHandler service. | |
| 26 // A ContentHandlerConnection can only be destroyed via CloseConnection. | |
| 27 // A ContentHandlerConnection manages its own lifetime and cannot be used with | |
| 28 // a scoped_ptr to avoid reentrant calls into ApplicationManager late in | |
| 29 // destruction. | |
| 30 class ContentHandlerConnection { | |
| 31 public: | |
| 32 using ClosedCallback = base::Callback<void(ContentHandlerConnection*)>; | |
| 33 // |id| is a unique identifier for this content handler. | |
| 34 ContentHandlerConnection(shell::ApplicationManager* manager, | |
| 35 const shell::Identity& source, | |
| 36 const shell::Identity& content_handler, | |
| 37 uint32_t id, | |
| 38 const ClosedCallback& connection_closed_callback); | |
| 39 | |
| 40 void StartApplication(InterfaceRequest<Application> request, | |
| 41 URLResponsePtr response); | |
| 42 | |
| 43 // Closes the connection and destroys |this| object. | |
| 44 void CloseConnection(); | |
| 45 | |
| 46 const shell::Identity& identity() const { return identity_; } | |
| 47 uint32_t id() const { return id_; } | |
| 48 | |
| 49 private: | |
| 50 ~ContentHandlerConnection(); | |
| 51 | |
| 52 void ApplicationDestructed(); | |
| 53 | |
| 54 ClosedCallback connection_closed_callback_; | |
| 55 shell::Identity identity_; | |
| 56 | |
| 57 ContentHandlerPtr content_handler_; | |
| 58 bool connection_closed_; | |
| 59 // The id for this content handler. | |
| 60 const uint32_t id_; | |
| 61 int ref_count_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(ContentHandlerConnection); | |
| 64 }; | |
| 65 | |
| 66 } // namespace package_manager | |
| 67 } // namespace mojo | |
| 68 | |
| 69 #endif // MOJO_PACKAGE_MANAGER_CONTENT_HANDLER_CONNECTION_H_ | |
| OLD | NEW |