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

Side by Side Diff: mojo/shell/application_instance.h

Issue 1307273004: Group ConnectToApplication-related info into a params struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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/BUILD.gn ('k') | mojo/shell/application_instance.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_APPLICATION_INSTANCE_H_ 5 #ifndef MOJO_SHELL_APPLICATION_INSTANCE_H_
6 #define MOJO_SHELL_APPLICATION_INSTANCE_H_ 6 #define MOJO_SHELL_APPLICATION_INSTANCE_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h"
11 #include "mojo/application/public/interfaces/application.mojom.h" 12 #include "mojo/application/public/interfaces/application.mojom.h"
12 #include "mojo/application/public/interfaces/shell.mojom.h" 13 #include "mojo/application/public/interfaces/shell.mojom.h"
13 #include "mojo/public/cpp/bindings/binding.h" 14 #include "mojo/public/cpp/bindings/binding.h"
14 #include "mojo/shell/capability_filter.h" 15 #include "mojo/shell/capability_filter.h"
16 #include "mojo/shell/connect_to_application_params.h"
15 #include "mojo/shell/identity.h" 17 #include "mojo/shell/identity.h"
16 #include "url/gurl.h" 18 #include "url/gurl.h"
17 19
18 namespace mojo { 20 namespace mojo {
19 namespace shell { 21 namespace shell {
20 22
21 class ApplicationManager; 23 class ApplicationManager;
22 24
23 // Encapsulates a connection to an instance of an application, tracked by the 25 // Encapsulates a connection to an instance of an application, tracked by the
24 // shell's ApplicationManager. 26 // shell's ApplicationManager.
25 class ApplicationInstance : public Shell { 27 class ApplicationInstance : public Shell {
26 public: 28 public:
27 // |requesting_content_handler_id| is the id of the content handler that 29 // |requesting_content_handler_id| is the id of the content handler that
28 // loaded this app. If the app was not loaded by a content handler the id 30 // loaded this app. If the app was not loaded by a content handler the id
29 // is kInvalidContentHandlerID. 31 // is kInvalidContentHandlerID.
30 ApplicationInstance(ApplicationPtr application, 32 ApplicationInstance(ApplicationPtr application,
31 ApplicationManager* manager, 33 ApplicationManager* manager,
32 const Identity& originator_identity, 34 const Identity& originator_identity,
33 const Identity& resolved_identity, 35 const Identity& resolved_identity,
34 const CapabilityFilter& filter, 36 const CapabilityFilter& filter,
35 uint32_t requesting_content_handler_id, 37 uint32_t requesting_content_handler_id,
36 const base::Closure& on_application_end); 38 const base::Closure& on_application_end);
37 39
38 ~ApplicationInstance() override; 40 ~ApplicationInstance() override;
39 41
40 void InitializeApplication(); 42 void InitializeApplication();
41 43
42 void ConnectToClient(ApplicationInstance* originator, 44 void ConnectToClient(scoped_ptr<ConnectToApplicationParams> params);
43 const GURL& requested_url,
44 const GURL& requestor_url,
45 InterfaceRequest<ServiceProvider> services,
46 ServiceProviderPtr exposed_services,
47 const CapabilityFilter& filter,
48 const ConnectToApplicationCallback& callback);
49
50 // Returns the set of interfaces this application instance is allowed to see
51 // from an instance with |identity|.
52 AllowedInterfaces GetAllowedInterfaces(const Identity& identity) const;
53 45
54 Application* application() { return application_.get(); } 46 Application* application() { return application_.get(); }
55 const Identity& identity() const { return identity_; } 47 const Identity& identity() const { return identity_; }
48 const CapabilityFilter& filter() const { return filter_; }
56 base::Closure on_application_end() const { return on_application_end_; } 49 base::Closure on_application_end() const { return on_application_end_; }
57 void set_requesting_content_handler_id(uint32_t id) { 50 void set_requesting_content_handler_id(uint32_t id) {
58 requesting_content_handler_id_ = id; 51 requesting_content_handler_id_ = id;
59 } 52 }
60 uint32_t requesting_content_handler_id() const { 53 uint32_t requesting_content_handler_id() const {
61 return requesting_content_handler_id_; 54 return requesting_content_handler_id_;
62 } 55 }
63 56
64 private: 57 private:
65 // Shell implementation: 58 // Shell implementation:
66 void ConnectToApplication( 59 void ConnectToApplication(
67 URLRequestPtr app_request, 60 URLRequestPtr app_request,
68 InterfaceRequest<ServiceProvider> services, 61 InterfaceRequest<ServiceProvider> services,
69 ServiceProviderPtr exposed_services, 62 ServiceProviderPtr exposed_services,
70 CapabilityFilterPtr filter, 63 CapabilityFilterPtr filter,
71 const ConnectToApplicationCallback& callback) override; 64 const ConnectToApplicationCallback& callback) override;
72 void QuitApplication() override; 65 void QuitApplication() override;
73 66
74 void CallAcceptConnection(ApplicationInstance* originator, 67 void CallAcceptConnection(scoped_ptr<ConnectToApplicationParams> params);
75 const GURL& url,
76 InterfaceRequest<ServiceProvider> services,
77 ServiceProviderPtr exposed_services,
78 const GURL& requested_url);
79 68
80 void OnConnectionError(); 69 void OnConnectionError();
81 70
82 void OnQuitRequestedResult(bool can_quit); 71 void OnQuitRequestedResult(bool can_quit);
83 72
84 struct QueuedClientRequest {
85 QueuedClientRequest();
86 ~QueuedClientRequest();
87 ApplicationInstance* originator;
88 GURL requested_url;
89 GURL requestor_url;
90 InterfaceRequest<ServiceProvider> services;
91 ServiceProviderPtr exposed_services;
92 CapabilityFilter filter;
93 ConnectToApplicationCallback connect_callback;
94 };
95
96 ApplicationManager* const manager_; 73 ApplicationManager* const manager_;
97 const Identity originator_identity_; 74 const Identity originator_identity_;
98 const Identity identity_; 75 const Identity identity_;
99 const CapabilityFilter filter_; 76 const CapabilityFilter filter_;
100 const bool allow_any_application_; 77 const bool allow_any_application_;
101 uint32_t requesting_content_handler_id_; 78 uint32_t requesting_content_handler_id_;
102 base::Closure on_application_end_; 79 base::Closure on_application_end_;
103 ApplicationPtr application_; 80 ApplicationPtr application_;
104 Binding<Shell> binding_; 81 Binding<Shell> binding_;
105 bool queue_requests_; 82 bool queue_requests_;
106 std::vector<QueuedClientRequest*> queued_client_requests_; 83 std::vector<ConnectToApplicationParams*> queued_client_requests_;
107 84
108 DISALLOW_COPY_AND_ASSIGN(ApplicationInstance); 85 DISALLOW_COPY_AND_ASSIGN(ApplicationInstance);
109 }; 86 };
110 87
111 } // namespace shell 88 } // namespace shell
112 } // namespace mojo 89 } // namespace mojo
113 90
114 #endif // MOJO_SHELL_APPLICATION_INSTANCE_H_ 91 #endif // MOJO_SHELL_APPLICATION_INSTANCE_H_
OLDNEW
« no previous file with comments | « mojo/shell/BUILD.gn ('k') | mojo/shell/application_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698