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

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

Issue 1728083002: Extract a Connector interface from Shell that can be cloned & passed to other threads (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@12uid
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/shell_connection.cc ('k') | mojo/shell/public/cpp/shell_connection.h » ('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
index f513f40d35a0f9425bd99833acec95311488e0ca..d333acb4e94611a215a52523706fc0af2a2ae6cd 100644
--- a/mojo/shell/public/cpp/shell.h
+++ b/mojo/shell/public/cpp/shell.h
@@ -6,16 +6,12 @@
#define MOJO_SHELL_PUBLIC_CPP_SHELL_H_
#include "mojo/shell/public/cpp/connection.h"
+#include "mojo/shell/public/cpp/connector.h"
#include "mojo/shell/public/interfaces/shell.mojom.h"
-#include "mojo/shell/public/interfaces/shell_client.mojom.h"
#include "url/gurl.h"
namespace mojo {
-shell::mojom::CapabilityFilterPtr CreatePermissiveCapabilityFilter();
-
-using ShellClientRequest = InterfaceRequest<shell::mojom::ShellClient>;
-
// An interface implementation can keep this object as a member variable to
// hold a reference to the ShellConnection, keeping it alive as long as the
// bound implementation exists.
@@ -35,39 +31,17 @@ class AppRefCount {
// ShellConnection, this is the primary interface exposed to clients.
class Shell {
public:
- class ConnectParams {
- public:
- explicit ConnectParams(const std::string& url);
- ~ConnectParams();
-
- const GURL& url() { return url_; }
- shell::mojom::CapabilityFilterPtr TakeFilter() {
- return std::move(filter_);
- }
- void set_filter(shell::mojom::CapabilityFilterPtr filter) {
- filter_ = std::move(filter);
- }
- void set_user_id(uint32_t user_id) { user_id_ = user_id; }
- uint32_t user_id() const { return user_id_; }
-
- private:
- GURL url_;
- shell::mojom::CapabilityFilterPtr filter_;
- uint32_t user_id_;
-
- 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<Connection> Connect(const std::string& url) = 0;
- virtual scoped_ptr<Connection> Connect(ConnectParams* params) = 0;
+ virtual scoped_ptr<Connection> Connect(Connector::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 ConnectToInterface(ConnectParams* params, InterfacePtr<Interface>* ptr) {
+ void ConnectToInterface(Connector::ConnectParams* params,
+ InterfacePtr<Interface>* ptr) {
scoped_ptr<Connection> connection = Connect(params);
if (connection)
connection->GetInterface(ptr);
@@ -75,11 +49,15 @@ class Shell {
template <typename Interface>
void ConnectToInterface(const std::string& url,
InterfacePtr<Interface>* ptr) {
- ConnectParams params(url);
+ Connector::ConnectParams params(url);
params.set_filter(CreatePermissiveCapabilityFilter());
return ConnectToInterface(&params, ptr);
}
+ // Returns a clone of the ShellConnection's Connector that can be passed to
+ // other threads.
+ virtual scoped_ptr<Connector> CloneConnector() const = 0;
+
// 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;
« no previous file with comments | « mojo/shell/public/cpp/lib/shell_connection.cc ('k') | mojo/shell/public/cpp/shell_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698