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

Side by Side Diff: mojo/shell/public/cpp/lib/connection_impl.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
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_SHELL_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_ 5 #ifndef MOJO_SHELL_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_
6 #define MOJO_SHELL_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_ 6 #define MOJO_SHELL_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 12
13 #include "mojo/public/cpp/bindings/binding.h" 13 #include "mojo/public/cpp/bindings/binding.h"
14 #include "mojo/shell/public/cpp/connection.h" 14 #include "mojo/shell/public/cpp/connection.h"
15 #include "mojo/shell/public/cpp/identity.h"
15 #include "mojo/shell/public/interfaces/connector.mojom.h" 16 #include "mojo/shell/public/interfaces/connector.mojom.h"
16 #include "mojo/shell/public/interfaces/interface_provider.mojom.h" 17 #include "mojo/shell/public/interfaces/interface_provider.mojom.h"
17 18
18 namespace mojo { 19 namespace mojo {
19 namespace internal { 20 namespace internal {
20 21
21 // A ConnectionImpl represents each half of a connection between two 22 // A ConnectionImpl represents each half of a connection between two
22 // applications, allowing customization of which interfaces are published to the 23 // applications, allowing customization of which interfaces are published to the
23 // other. 24 // other.
24 class ConnectionImpl : public Connection { 25 class ConnectionImpl : public Connection {
25 public: 26 public:
26 ConnectionImpl(); 27 ConnectionImpl();
27 // |allowed_interfaces| are the set of interfaces that the shell has allowed 28 // |allowed_interfaces| are the set of interfaces that the shell has allowed
28 // an application to expose to another application. If this set contains only 29 // an application to expose to another application. If this set contains only
29 // the string value "*" all interfaces may be exposed. 30 // the string value "*" all interfaces may be exposed.
30 ConnectionImpl(const std::string& connection_name, 31 ConnectionImpl(const std::string& connection_name,
31 const std::string& remote_name, 32 const Identity& remote,
32 uint32_t remote_id, 33 uint32_t remote_id,
33 const std::string& remote_user_id,
34 shell::mojom::InterfaceProviderPtr remote_interfaces, 34 shell::mojom::InterfaceProviderPtr remote_interfaces,
35 shell::mojom::InterfaceProviderRequest local_interfaces, 35 shell::mojom::InterfaceProviderRequest local_interfaces,
36 const std::set<std::string>& allowed_interfaces, 36 const std::set<std::string>& allowed_interfaces,
37 State initial_state); 37 State initial_state);
38 ~ConnectionImpl() override; 38 ~ConnectionImpl() override;
39 39
40 shell::mojom::Connector::ConnectCallback GetConnectCallback(); 40 shell::mojom::Connector::ConnectCallback GetConnectCallback();
41 41
42 private: 42 private:
43 // Connection: 43 // Connection:
44 const std::string& GetConnectionName() override; 44 const std::string& GetConnectionName() override;
45 const std::string& GetRemoteApplicationName() override; 45 const Identity& GetRemoteIdentity() const override;
46 const std::string& GetRemoteUserID() const override;
47 void SetConnectionLostClosure(const Closure& handler) override; 46 void SetConnectionLostClosure(const Closure& handler) override;
48 shell::mojom::ConnectResult GetResult() const override; 47 shell::mojom::ConnectResult GetResult() const override;
49 bool IsPending() const override; 48 bool IsPending() const override;
50 uint32_t GetRemoteInstanceID() const override; 49 uint32_t GetRemoteInstanceID() const override;
51 void AddConnectionCompletedClosure(const Closure& callback) override; 50 void AddConnectionCompletedClosure(const Closure& callback) override;
52 bool AllowsInterface(const std::string& interface_name) const override; 51 bool AllowsInterface(const std::string& interface_name) const override;
53 shell::mojom::InterfaceProvider* GetRemoteInterfaces() override; 52 shell::mojom::InterfaceProvider* GetRemoteInterfaces() override;
54 InterfaceRegistry* GetLocalRegistry() override; 53 InterfaceRegistry* GetLocalRegistry() override;
55 base::WeakPtr<Connection> GetWeakPtr() override; 54 base::WeakPtr<Connection> GetWeakPtr() override;
56 55
57 void OnConnectionCompleted(shell::mojom::ConnectResult result, 56 void OnConnectionCompleted(shell::mojom::ConnectResult result,
58 const std::string& target_user_id, 57 const std::string& target_user_id,
59 uint32_t target_application_id); 58 uint32_t target_application_id);
60 59
61 const std::string connection_name_; 60 const std::string connection_name_;
62 const std::string remote_name_; 61 Identity remote_;
62 uint32_t remote_id_ = shell::mojom::kInvalidInstanceID;
63 63
64 State state_; 64 State state_;
65 shell::mojom::ConnectResult result_ = shell::mojom::ConnectResult::SUCCEEDED; 65 shell::mojom::ConnectResult result_ = shell::mojom::ConnectResult::SUCCEEDED;
66 uint32_t remote_id_ = shell::mojom::kInvalidInstanceID;
67 std::vector<Closure> connection_completed_callbacks_; 66 std::vector<Closure> connection_completed_callbacks_;
68 std::string remote_user_id_ = shell::mojom::kInheritUserID;
69 67
70 InterfaceRegistry local_registry_; 68 InterfaceRegistry local_registry_;
71 shell::mojom::InterfaceProviderPtr remote_interfaces_; 69 shell::mojom::InterfaceProviderPtr remote_interfaces_;
72 70
73 const std::set<std::string> allowed_interfaces_; 71 const std::set<std::string> allowed_interfaces_;
74 const bool allow_all_interfaces_; 72 const bool allow_all_interfaces_;
75 73
76 base::WeakPtrFactory<ConnectionImpl> weak_factory_; 74 base::WeakPtrFactory<ConnectionImpl> weak_factory_;
77 75
78 DISALLOW_COPY_AND_ASSIGN(ConnectionImpl); 76 DISALLOW_COPY_AND_ASSIGN(ConnectionImpl);
79 }; 77 };
80 78
81 } // namespace internal 79 } // namespace internal
82 } // namespace mojo 80 } // namespace mojo
83 81
84 #endif // MOJO_SHELL_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_ 82 #endif // MOJO_SHELL_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_
OLDNEW
« no previous file with comments | « mojo/shell/public/cpp/lib/application_test_base.cc ('k') | mojo/shell/public/cpp/lib/connection_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698