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

Unified Diff: mojo/shell/public/cpp/shell.h

Issue 1674903003: Extract shell methods from ApplicationImpl into a base class, and pass this to Initialize() instead. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojom
Patch Set: . Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/shell/public/cpp/lib/content_handler_factory.cc ('k') | mojo/shell/runner/child/native_apptest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/public/cpp/shell.h
diff --git a/mojo/shell/public/cpp/shell.h b/mojo/shell/public/cpp/shell.h
new file mode 100644
index 0000000000000000000000000000000000000000..2a3acb34ef006f03e232decaff26d3f4b586abb3
--- /dev/null
+++ b/mojo/shell/public/cpp/shell.h
@@ -0,0 +1,78 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_SHELL_PUBLIC_CPP_SHELL_H_
+#define MOJO_SHELL_PUBLIC_CPP_SHELL_H_
+
+#include "mojo/shell/public/cpp/app_lifetime_helper.h"
+#include "mojo/shell/public/cpp/application_connection.h"
+#include "mojo/shell/public/interfaces/application.mojom.h"
+#include "mojo/shell/public/interfaces/shell.mojom.h"
+
+namespace mojo {
+
+shell::mojom::CapabilityFilterPtr CreatePermissiveCapabilityFilter();
+
+using ApplicationRequest = InterfaceRequest<shell::mojom::Application>;
+
+class Shell {
+ public:
+ class ConnectParams {
+ public:
+ explicit ConnectParams(const std::string& url);
+ explicit ConnectParams(URLRequestPtr request);
+ ~ConnectParams();
+
+ URLRequestPtr TakeRequest() { return std::move(request_); }
+ shell::mojom::CapabilityFilterPtr TakeFilter() {
+ return std::move(filter_);
+ }
+ void set_filter(shell::mojom::CapabilityFilterPtr filter) {
+ filter_ = std::move(filter);
+ }
+
+ private:
+ URLRequestPtr request_;
+ shell::mojom::CapabilityFilterPtr filter_;
+
+ DISALLOW_COPY_AND_ASSIGN(ConnectParams);
+ };
+
+ // Requests a new connection to an application. Returns a pointer to the
+ // connection if the connection is permitted by this application's delegate,
+ // or nullptr otherwise. Caller takes ownership.
+ virtual scoped_ptr<ApplicationConnection> ConnectToApplication(
+ const std::string& url) = 0;
+ virtual scoped_ptr<ApplicationConnection> ConnectToApplication(
+ ConnectParams* params) = 0;
+
+ // Connect to application identified by |request->url| and connect to the
+ // service implementation of the interface identified by |Interface|.
+ template <typename Interface>
+ void ConnectToService(ConnectParams* params, InterfacePtr<Interface>* ptr) {
+ scoped_ptr<ApplicationConnection> connection = ConnectToApplication(params);
+ if (!connection.get())
+ return;
+ connection->ConnectToService(ptr);
+ }
+ template <typename Interface>
+ void ConnectToService(const std::string& url, InterfacePtr<Interface>* ptr) {
+ ConnectParams params(url);
+ params.set_filter(CreatePermissiveCapabilityFilter());
+ return ConnectToService(&params, ptr);
+ }
+
+ // Initiate shutdown of this application. This may involve a round trip to the
+ // Shell to ensure there are no inbound service requests.
+ virtual void Quit() = 0;
+
+ // Create an object that can be used to refcount the lifetime of the
+ // application. The returned object may be cloned, and when the refcount falls
+ // to zero Quit() is called.
+ virtual scoped_ptr<AppRefCount> CreateAppRefCount() = 0;
+};
+
+} // namespace mojo
+
+#endif // MOJO_SHELL_PUBLIC_CPP_SHELL_H_
« no previous file with comments | « mojo/shell/public/cpp/lib/content_handler_factory.cc ('k') | mojo/shell/runner/child/native_apptest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698