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

Side by Side Diff: mojo/shell/public/cpp/connector.h

Issue 1769163002: Add a instance groups to Connect(), and introduce an Identity struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 9 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
« no previous file with comments | « mojo/shell/public/cpp/connection.h ('k') | mojo/shell/public/cpp/identity.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_SHELL_PUBLIC_CPP_CONNECTOR_H_ 5 #ifndef MOJO_SHELL_PUBLIC_CPP_CONNECTOR_H_
6 #define MOJO_SHELL_PUBLIC_CPP_CONNECTOR_H_ 6 #define MOJO_SHELL_PUBLIC_CPP_CONNECTOR_H_
7 7
8 #include "mojo/shell/public/cpp/connection.h" 8 #include "mojo/shell/public/cpp/connection.h"
9 #include "mojo/shell/public/cpp/identity.h"
9 #include "mojo/shell/public/interfaces/connector.mojom.h" 10 #include "mojo/shell/public/interfaces/connector.mojom.h"
10 11
11 namespace mojo { 12 namespace mojo {
12 13
13 // An interface that encapsulates the Mojo Shell's broker interface by which 14 // An interface that encapsulates the Mojo Shell's broker interface by which
14 // connections between applications are established. Once Connect() is called, 15 // connections between applications are established. Once Connect() is called,
15 // this class is bound to the thread the call was made on and it cannot be 16 // this class is bound to the thread the call was made on and it cannot be
16 // passed to another thread without calling Clone(). 17 // passed to another thread without calling Clone().
17 // An instance of this class is created internally by ShellConnection for use 18 // An instance of this class is created internally by ShellConnection for use
18 // on the thread ShellConnection is instantiated on, and this interface is 19 // on the thread ShellConnection is instantiated on, and this interface is
19 // wrapped by the Shell interface. 20 // wrapped by the Shell interface.
20 // To use this interface on other threads, call Shell::CloneConnector() and 21 // To use this interface on other threads, call Shell::CloneConnector() and
21 // pass the result to another thread. To pass to subsequent threads, call 22 // pass the result to another thread. To pass to subsequent threads, call
22 // Clone() on instances of this object. 23 // Clone() on instances of this object.
23 // While instances of this object are owned by the caller, the underlying 24 // While instances of this object are owned by the caller, the underlying
24 // connection with the shell is bound to the lifetime of the instance that 25 // connection with the shell is bound to the lifetime of the instance that
25 // created it, i.e. when the application is terminated the Connector pipe is 26 // created it, i.e. when the application is terminated the Connector pipe is
26 // closed. 27 // closed.
27 class Connector { 28 class Connector {
28 public: 29 public:
29 virtual ~Connector() {} 30 virtual ~Connector() {}
30 31
31 class ConnectParams { 32 class ConnectParams {
32 public: 33 public:
34 explicit ConnectParams(const Identity& target);
33 explicit ConnectParams(const std::string& name); 35 explicit ConnectParams(const std::string& name);
34 ~ConnectParams(); 36 ~ConnectParams();
35 37
36 const std::string& name() { return name_; } 38 const Identity& target() { return target_; }
37 void set_user_id(const std::string& user_id) { user_id_ = user_id; } 39 void set_target(const Identity& target) { target_ = target; }
38 const std::string& user_id() const { return user_id_; }
39 40
40 private: 41 private:
41 std::string name_; 42 Identity target_;
42 std::string user_id_;
43 43
44 DISALLOW_COPY_AND_ASSIGN(ConnectParams); 44 DISALLOW_COPY_AND_ASSIGN(ConnectParams);
45 }; 45 };
46 46
47 // Requests a new connection to an application. Returns a pointer to the 47 // Requests a new connection to an application. Returns a pointer to the
48 // connection if the connection is permitted by this application's delegate, 48 // connection if the connection is permitted by this application's delegate,
49 // or nullptr otherwise. Caller takes ownership. 49 // or nullptr otherwise. Caller takes ownership.
50 // Once this method is called, this object is bound to the thread on which the 50 // Once this method is called, this object is bound to the thread on which the
51 // call took place. To pass to another thread, call Clone() and pass the 51 // call took place. To pass to another thread, call Clone() and pass the
52 // result. 52 // result.
(...skipping 17 matching lines...) Expand all
70 70
71 // Creates a new instance of this class which may be passed to another thread. 71 // Creates a new instance of this class which may be passed to another thread.
72 // The returned object may be passed multiple times until Connect() is called, 72 // The returned object may be passed multiple times until Connect() is called,
73 // at which point this method must be called again to pass again. 73 // at which point this method must be called again to pass again.
74 virtual scoped_ptr<Connector> Clone() = 0; 74 virtual scoped_ptr<Connector> Clone() = 0;
75 }; 75 };
76 76
77 } // namespace mojo 77 } // namespace mojo
78 78
79 #endif // MOJO_SHELL_PUBLIC_CPP_CONNECTOR_H_ 79 #endif // MOJO_SHELL_PUBLIC_CPP_CONNECTOR_H_
OLDNEW
« no previous file with comments | « mojo/shell/public/cpp/connection.h ('k') | mojo/shell/public/cpp/identity.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698