| 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 MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ | 5 #ifndef MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ |
| 6 #define MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ | 6 #define MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | |
| 11 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 12 #include "mojo/application/public/cpp/app_lifetime_helper.h" | 11 #include "mojo/application/public/cpp/app_lifetime_helper.h" |
| 13 #include "mojo/application/public/cpp/application_connection.h" | 12 #include "mojo/application/public/cpp/application_connection.h" |
| 14 #include "mojo/application/public/cpp/application_delegate.h" | 13 #include "mojo/application/public/cpp/application_delegate.h" |
| 15 #include "mojo/application/public/cpp/lib/service_registry.h" | 14 #include "mojo/application/public/cpp/lib/service_registry.h" |
| 16 #include "mojo/application/public/interfaces/application.mojom.h" | 15 #include "mojo/application/public/interfaces/application.mojom.h" |
| 17 #include "mojo/application/public/interfaces/shell.mojom.h" | 16 #include "mojo/application/public/interfaces/shell.mojom.h" |
| 17 #include "mojo/public/cpp/bindings/callback.h" |
| 18 #include "mojo/public/cpp/system/core.h" | 18 #include "mojo/public/cpp/system/core.h" |
| 19 | 19 |
| 20 namespace mojo { | 20 namespace mojo { |
| 21 | 21 |
| 22 // Utility class for communicating with the Shell, and providing Services | 22 // Utility class for communicating with the Shell, and providing Services |
| 23 // to clients. | 23 // to clients. |
| 24 // | 24 // |
| 25 // To use define a class that implements your specific server api, e.g. FooImpl | 25 // To use define a class that implements your specific server api, e.g. FooImpl |
| 26 // to implement a service named Foo. | 26 // to implement a service named Foo. |
| 27 // That class must subclass an InterfaceImpl specialization. | 27 // That class must subclass an InterfaceImpl specialization. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 56 public: | 56 public: |
| 57 // Does not take ownership of |delegate|, which must remain valid for the | 57 // Does not take ownership of |delegate|, which must remain valid for the |
| 58 // lifetime of ApplicationImpl. | 58 // lifetime of ApplicationImpl. |
| 59 ApplicationImpl(ApplicationDelegate* delegate, | 59 ApplicationImpl(ApplicationDelegate* delegate, |
| 60 InterfaceRequest<Application> request); | 60 InterfaceRequest<Application> request); |
| 61 // Constructs an ApplicationImpl with a custom termination closure. This | 61 // Constructs an ApplicationImpl with a custom termination closure. This |
| 62 // closure is invoked on Terminate() instead of the default behavior of | 62 // closure is invoked on Terminate() instead of the default behavior of |
| 63 // quitting the current MessageLoop. | 63 // quitting the current MessageLoop. |
| 64 ApplicationImpl(ApplicationDelegate* delegate, | 64 ApplicationImpl(ApplicationDelegate* delegate, |
| 65 InterfaceRequest<Application> request, | 65 InterfaceRequest<Application> request, |
| 66 const base::Closure& termination_closure); | 66 const Closure& termination_closure); |
| 67 ~ApplicationImpl() override; | 67 ~ApplicationImpl() override; |
| 68 | 68 |
| 69 // The Mojo shell. This will return a valid pointer after Initialize() has | 69 // The Mojo shell. This will return a valid pointer after Initialize() has |
| 70 // been invoked. It will remain valid until UnbindConnections() is invoked or | 70 // been invoked. It will remain valid until UnbindConnections() is invoked or |
| 71 // the ApplicationImpl is destroyed. | 71 // the ApplicationImpl is destroyed. |
| 72 Shell* shell() const { return shell_.get(); } | 72 Shell* shell() const { return shell_.get(); } |
| 73 | 73 |
| 74 const std::string& url() const { return url_; } | 74 const std::string& url() const { return url_; } |
| 75 | 75 |
| 76 AppLifetimeHelper* app_lifetime_helper() { return &app_lifetime_helper_; } | 76 AppLifetimeHelper* app_lifetime_helper() { return &app_lifetime_helper_; } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 void ClearConnections(); | 134 void ClearConnections(); |
| 135 | 135 |
| 136 typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList; | 136 typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList; |
| 137 | 137 |
| 138 ServiceRegistryList incoming_service_registries_; | 138 ServiceRegistryList incoming_service_registries_; |
| 139 ServiceRegistryList outgoing_service_registries_; | 139 ServiceRegistryList outgoing_service_registries_; |
| 140 ApplicationDelegate* delegate_; | 140 ApplicationDelegate* delegate_; |
| 141 Binding<Application> binding_; | 141 Binding<Application> binding_; |
| 142 ShellPtr shell_; | 142 ShellPtr shell_; |
| 143 std::string url_; | 143 std::string url_; |
| 144 base::Closure termination_closure_; | 144 Closure termination_closure_; |
| 145 AppLifetimeHelper app_lifetime_helper_; | 145 AppLifetimeHelper app_lifetime_helper_; |
| 146 bool quit_requested_; | 146 bool quit_requested_; |
| 147 bool in_destructor_; | 147 bool in_destructor_; |
| 148 base::WeakPtrFactory<ApplicationImpl> weak_factory_; | 148 base::WeakPtrFactory<ApplicationImpl> weak_factory_; |
| 149 | 149 |
| 150 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); | 150 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); |
| 151 }; | 151 }; |
| 152 | 152 |
| 153 } // namespace mojo | 153 } // namespace mojo |
| 154 | 154 |
| 155 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ | 155 #endif // MOJO_APPLICATION_PUBLIC_CPP_APPLICATION_IMPL_H_ |
| OLD | NEW |