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

Side by Side Diff: shell/application_manager/shell_impl.h

Issue 1682113003: Mojo C++ bindings: Generate InterfaceHandle<> instead of InterfacePtr<>. (Closed) Base URL: https://github.com/domokit/mojo.git@master
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 unified diff | Download patch
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 SHELL_APPLICATION_MANAGER_SHELL_IMPL_H_ 5 #ifndef SHELL_APPLICATION_MANAGER_SHELL_IMPL_H_
6 #define SHELL_APPLICATION_MANAGER_SHELL_IMPL_H_ 6 #define SHELL_APPLICATION_MANAGER_SHELL_IMPL_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "mojo/common/binding_set.h" 10 #include "mojo/common/binding_set.h"
11 #include "mojo/public/cpp/bindings/binding.h" 11 #include "mojo/public/cpp/bindings/binding.h"
12 #include "mojo/public/cpp/bindings/interface_handle.h"
12 #include "mojo/public/interfaces/application/application.mojom.h" 13 #include "mojo/public/interfaces/application/application.mojom.h"
13 #include "mojo/public/interfaces/application/application_connector.mojom.h" 14 #include "mojo/public/interfaces/application/application_connector.mojom.h"
14 #include "mojo/public/interfaces/application/shell.mojom.h" 15 #include "mojo/public/interfaces/application/shell.mojom.h"
15 #include "shell/application_manager/identity.h" 16 #include "shell/application_manager/identity.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
17 18
18 namespace shell { 19 namespace shell {
19 20
20 class ApplicationManager; 21 class ApplicationManager;
21 22
22 // TODO(vtl): This both implements the |Shell| interface and holds the 23 // TODO(vtl): This both implements the |Shell| interface and holds the
23 // |ApplicationPtr| (from back when they were paired interfaces on the same 24 // |ApplicationPtr| (from back when they were paired interfaces on the same
24 // message pipe). The way it manages lifetime is dubious/wrong. We should have 25 // message pipe). The way it manages lifetime is dubious/wrong. We should have
25 // an object holding stuff associated to an application, namely its "real" 26 // an object holding stuff associated to an application, namely its "real"
26 // |ShellImpl|, its |ApplicationPtr|, and tracking its |ApplicationConnector|s. 27 // |ShellImpl|, its |ApplicationPtr|, and tracking its |ApplicationConnector|s.
27 class ShellImpl : public mojo::Shell { 28 class ShellImpl : public mojo::Shell {
28 public: 29 public:
29 ShellImpl(mojo::ApplicationPtr application, 30 ShellImpl(mojo::ApplicationPtr application,
30 ApplicationManager* manager, 31 ApplicationManager* manager,
31 const Identity& resolved_identity, 32 const Identity& resolved_identity,
32 const base::Closure& on_application_end); 33 const base::Closure& on_application_end);
33 34
34 ~ShellImpl() override; 35 ~ShellImpl() override;
35 36
36 void InitializeApplication(mojo::Array<mojo::String> args); 37 void InitializeApplication(mojo::Array<mojo::String> args);
37 38
38 void ConnectToClient(const GURL& requested_url, 39 void ConnectToClient(
39 const GURL& requestor_url, 40 const GURL& requested_url,
40 mojo::InterfaceRequest<mojo::ServiceProvider> services, 41 const GURL& requestor_url,
41 mojo::ServiceProviderPtr exposed_services); 42 mojo::InterfaceRequest<mojo::ServiceProvider> services,
43 mojo::InterfaceHandle<mojo::ServiceProvider> exposed_services);
42 44
43 mojo::Application* application() { return application_.get(); } 45 mojo::Application* application() { return application_.get(); }
44 const Identity& identity() const { return identity_; } 46 const Identity& identity() const { return identity_; }
45 base::Closure on_application_end() const { return on_application_end_; } 47 base::Closure on_application_end() const { return on_application_end_; }
46 48
47 private: 49 private:
48 // This is a per-|ShellImpl| singleton. 50 // This is a per-|ShellImpl| singleton.
49 class ApplicationConnectorImpl : public mojo::ApplicationConnector { 51 class ApplicationConnectorImpl : public mojo::ApplicationConnector {
50 public: 52 public:
51 explicit ApplicationConnectorImpl(mojo::Shell* shell); 53 explicit ApplicationConnectorImpl(mojo::Shell* shell);
52 ~ApplicationConnectorImpl() override; 54 ~ApplicationConnectorImpl() override;
53 55
54 void ConnectToApplication( 56 void ConnectToApplication(
55 const mojo::String& app_url, 57 const mojo::String& app_url,
56 mojo::InterfaceRequest<mojo::ServiceProvider> services, 58 mojo::InterfaceRequest<mojo::ServiceProvider> services,
57 mojo::ServiceProviderPtr exposed_services) override; 59 mojo::InterfaceHandle<mojo::ServiceProvider> exposed_services) override;
58 void Duplicate(mojo::InterfaceRequest<mojo::ApplicationConnector> 60 void Duplicate(mojo::InterfaceRequest<mojo::ApplicationConnector>
59 application_connector_request) override; 61 application_connector_request) override;
60 62
61 private: 63 private:
62 mojo::Shell* const shell_; 64 mojo::Shell* const shell_;
63 mojo::BindingSet<mojo::ApplicationConnector> bindings_; 65 mojo::BindingSet<mojo::ApplicationConnector> bindings_;
64 66
65 DISALLOW_COPY_AND_ASSIGN(ApplicationConnectorImpl); 67 DISALLOW_COPY_AND_ASSIGN(ApplicationConnectorImpl);
66 }; 68 };
67 69
68 // mojo::Shell implementation: 70 // mojo::Shell implementation:
69 void ConnectToApplication( 71 void ConnectToApplication(
70 const mojo::String& app_url, 72 const mojo::String& app_url,
71 mojo::InterfaceRequest<mojo::ServiceProvider> services, 73 mojo::InterfaceRequest<mojo::ServiceProvider> services,
72 mojo::ServiceProviderPtr exposed_services) override; 74 mojo::InterfaceHandle<mojo::ServiceProvider> exposed_services) override;
73 void CreateApplicationConnector( 75 void CreateApplicationConnector(
74 mojo::InterfaceRequest<mojo::ApplicationConnector> 76 mojo::InterfaceRequest<mojo::ApplicationConnector>
75 application_connector_request) override; 77 application_connector_request) override;
76 78
77 ApplicationManager* const manager_; 79 ApplicationManager* const manager_;
78 const Identity identity_; 80 const Identity identity_;
79 base::Closure on_application_end_; 81 base::Closure on_application_end_;
80 mojo::ApplicationPtr application_; 82 mojo::ApplicationPtr application_;
81 mojo::Binding<mojo::Shell> binding_; 83 mojo::Binding<mojo::Shell> binding_;
82 84
83 ApplicationConnectorImpl application_connector_impl_; 85 ApplicationConnectorImpl application_connector_impl_;
84 86
85 DISALLOW_COPY_AND_ASSIGN(ShellImpl); 87 DISALLOW_COPY_AND_ASSIGN(ShellImpl);
86 }; 88 };
87 89
88 } // namespace shell 90 } // namespace shell
89 91
90 #endif // SHELL_APPLICATION_MANAGER_SHELL_IMPL_H_ 92 #endif // SHELL_APPLICATION_MANAGER_SHELL_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698