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

Unified Diff: mojo/public/cpp/application/application_impl_base.h

Issue 2004493002: Add a mojo::RunApplication() for running implementations of ApplicationImplBase. (Closed) Base URL: https://github.com/domokit/mojo.git@work790_environment_no_instantiate
Patch Set: rebased Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/cpp/application/BUILD.gn ('k') | mojo/public/cpp/application/lib/application_impl_base.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/application/application_impl_base.h
diff --git a/mojo/public/cpp/application/application_impl_base.h b/mojo/public/cpp/application/application_impl_base.h
index 8d3cbf6087f93e9f8f2ae7a150d4996707052489..1553e5d29be94ad63ea63d1f372c2b88aefae5ad 100644
--- a/mojo/public/cpp/application/application_impl_base.h
+++ b/mojo/public/cpp/application/application_impl_base.h
@@ -26,12 +26,16 @@ class ServiceProviderImpl;
// To use this class, subclass it and implement/override the required methods
// (see below).
//
+// Note that by default |ApplicationImplBase|s are not "strongly bound" to their
+// |Application| requests (so, e.g., they can thus be constructed on the stack).
+// A subclass may make itself strongly bound by setting a suitable connection
+// error handler on the binding (available via |application_binding()|).
+//
// TODO(vtl): ApplicationRunners should take this instead of an
// ApplicationDelegate. Write more here when that's true (it's pretty hard to
// use this class in the current setup).
class ApplicationImplBase : public Application {
public:
- ApplicationImplBase();
~ApplicationImplBase() override;
// Binds the given |Application| request to this object. This must be done
@@ -48,30 +52,41 @@ class ApplicationImplBase : public Application {
// until this object is destroyed.
Shell* shell() const { return shell_.get(); }
+ // Returns this object's |Application| binding (set up by |Bind()|; of course,
+ // you can always manipulate it directly).
+ const Binding<Application>& application_binding() const {
+ return application_binding_;
+ }
+ Binding<Application>& application_binding() { return application_binding_; }
+
// Returns any initial configuration arguments, passed by the shell.
const std::vector<std::string>& args() const { return args_; }
bool HasArg(const std::string& arg) const;
const std::string& url() const { return url_; }
- // Methods to be implemented/overridden by subclasses:
+ // Methods to be overridden (if desired) by subclasses:
// Called after |Initialize()| has been received (|shell()|, |args()|, and
// |url()| will be valid when this is called. The default implementation does
// nothing.
- virtual void OnInitialize() {}
+ virtual void OnInitialize();
// Called when another application connects to this application (i.e., we
// receive |AcceptConnection()|). This should either configure what services
// are "provided" (made available via a |ServiceProvider|) to that application
// and return true, or this may return false to reject the connection
- // entirely.
- virtual bool OnAcceptConnection(
- ServiceProviderImpl* service_provider_impl) = 0;
+ // entirely. The default implementation rejects all connections (by just
+ // returning false).
+ virtual bool OnAcceptConnection(ServiceProviderImpl* service_provider_impl);
// Called before quitting the main message (run) loop, i.e., before
// |Terminate()|. The default implementation does nothing.
- virtual void OnQuit() {}
+ virtual void OnQuit();
+
+ protected:
+ // This class is meant to be subclassed.
+ ApplicationImplBase();
private:
// |Application| implementation. In general, you probably shouldn't call these
« no previous file with comments | « mojo/public/cpp/application/BUILD.gn ('k') | mojo/public/cpp/application/lib/application_impl_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698