Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Side by Side Diff: mojo/public/cpp/application/application_impl.h

Issue 947253003: Add ApplicationDelegate::Quit() (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_PUBLIC_APPLICATION_APPLICATION_IMPL_H_ 5 #ifndef MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_
6 #define MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_ 6 #define MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_
7 #include <vector> 7 #include <vector>
8 8
9 #include "mojo/public/cpp/application/application_connection.h" 9 #include "mojo/public/cpp/application/application_connection.h"
10 #include "mojo/public/cpp/application/application_delegate.h"
10 #include "mojo/public/cpp/application/lib/service_connector.h" 11 #include "mojo/public/cpp/application/lib/service_connector.h"
11 #include "mojo/public/cpp/application/lib/service_registry.h" 12 #include "mojo/public/cpp/application/lib/service_registry.h"
12 #include "mojo/public/cpp/system/core.h" 13 #include "mojo/public/cpp/system/core.h"
13 #include "mojo/public/interfaces/application/application.mojom.h" 14 #include "mojo/public/interfaces/application/application.mojom.h"
14 #include "mojo/public/interfaces/application/shell.mojom.h" 15 #include "mojo/public/interfaces/application/shell.mojom.h"
15 16
16 namespace mojo { 17 namespace mojo {
17 18
18 class ApplicationDelegate;
19
20 // Utility class for communicating with the Shell, and providing Services 19 // Utility class for communicating with the Shell, and providing Services
21 // to clients. 20 // to clients.
22 // 21 //
23 // To use define a class that implements your specific server api, e.g. FooImpl 22 // To use define a class that implements your specific server api, e.g. FooImpl
24 // to implement a service named Foo. 23 // to implement a service named Foo.
25 // That class must subclass an InterfaceImpl specialization. 24 // That class must subclass an InterfaceImpl specialization.
26 // 25 //
27 // If there is context that is to be shared amongst all instances, define a 26 // If there is context that is to be shared amongst all instances, define a
28 // constructor with that class as its only argument, otherwise define an empty 27 // constructor with that class as its only argument, otherwise define an empty
29 // constructor. 28 // constructor.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 99
101 // Quits the main run loop for this application. 100 // Quits the main run loop for this application.
102 static void Terminate(); 101 static void Terminate();
103 102
104 private: 103 private:
105 class ShellPtrWatcher; 104 class ShellPtrWatcher;
106 105
107 void ClearConnections(); 106 void ClearConnections();
108 107
109 void OnShellError() { 108 void OnShellError() {
109 delegate_->Quit();
110 ClearConnections(); 110 ClearConnections();
111 Terminate(); 111 Terminate();
112 } 112 }
113 113
114 // Application implementation. 114 // Application implementation.
115 void AcceptConnection(const String& requestor_url, 115 void AcceptConnection(const String& requestor_url,
116 InterfaceRequest<ServiceProvider> services, 116 InterfaceRequest<ServiceProvider> services,
117 ServiceProviderPtr exposed_services) override; 117 ServiceProviderPtr exposed_services) override;
118 118
119 void RequestQuit() override; 119 void RequestQuit() override;
120 120
121 typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList; 121 typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList;
122 122
123 ServiceRegistryList incoming_service_registries_; 123 ServiceRegistryList incoming_service_registries_;
124 ServiceRegistryList outgoing_service_registries_; 124 ServiceRegistryList outgoing_service_registries_;
125 ApplicationDelegate* delegate_; 125 ApplicationDelegate* delegate_;
126 Binding<Application> binding_; 126 Binding<Application> binding_;
127 ShellPtr shell_; 127 ShellPtr shell_;
128 ShellPtrWatcher* shell_watch_; 128 ShellPtrWatcher* shell_watch_;
129 std::string url_; 129 std::string url_;
130 std::vector<std::string> args_; 130 std::vector<std::string> args_;
131 131
132 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); 132 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl);
133 }; 133 };
134 134
135 } // namespace mojo 135 } // namespace mojo
136 136
137 #endif // MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_ 137 #endif // MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698