Chromium Code Reviews

Side by Side Diff: mojo/public/cpp/application/application_impl.h

Issue 1983263002: Replace ApplicationImpl::CreateApplicationConnector() with a standalone helper function. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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_PUBLIC_CPP_APPLICATION_APPLICATION_IMPL_H_ 5 #ifndef MOJO_PUBLIC_CPP_APPLICATION_APPLICATION_IMPL_H_
6 #define MOJO_PUBLIC_CPP_APPLICATION_APPLICATION_IMPL_H_ 6 #define MOJO_PUBLIC_CPP_APPLICATION_APPLICATION_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "mojo/public/cpp/application/application_delegate.h" 12 #include "mojo/public/cpp/application/application_delegate.h"
13 #include "mojo/public/cpp/system/macros.h" 13 #include "mojo/public/cpp/system/macros.h"
14 #include "mojo/public/interfaces/application/application.mojom.h" 14 #include "mojo/public/interfaces/application/application.mojom.h"
15 #include "mojo/public/interfaces/application/application_connector.mojom.h"
16 #include "mojo/public/interfaces/application/shell.mojom.h" 15 #include "mojo/public/interfaces/application/shell.mojom.h"
17 16
18 namespace mojo { 17 namespace mojo {
19 18
20 class ServiceProviderImpl; 19 class ServiceProviderImpl;
21 20
22 // Implements the Application interface, which the shell uses for basic 21 // Implements the Application interface, which the shell uses for basic
23 // communication with an application (e.g., to connect clients to services 22 // communication with an application (e.g., to connect clients to services
24 // provided by an application). Also provides the application access to the 23 // provided by an application). Also provides the application access to the
25 // Shell, which, e.g., may be used by an application to connect to other 24 // Shell, which, e.g., may be used by an application to connect to other
(...skipping 22 matching lines...)
48 // been invoked. It will remain valid until UnbindConnections() is invoked or 47 // been invoked. It will remain valid until UnbindConnections() is invoked or
49 // the ApplicationImpl is destroyed. 48 // the ApplicationImpl is destroyed.
50 Shell* shell() const { return shell_.get(); } 49 Shell* shell() const { return shell_.get(); }
51 50
52 const std::string& url() const { return url_; } 51 const std::string& url() const { return url_; }
53 52
54 // Returns any initial configuration arguments, passed by the Shell. 53 // Returns any initial configuration arguments, passed by the Shell.
55 const std::vector<std::string>& args() const { return args_; } 54 const std::vector<std::string>& args() const { return args_; }
56 bool HasArg(const std::string& arg) const; 55 bool HasArg(const std::string& arg) const;
57 56
58 // Creates a new |ApplicationConnector|. The result can be bound to an
59 // |ApplicationConnectorPtr| and used to connect to other applications. (It
60 // returns an |InterfaceHandle| instead of an |InterfacePtr| to facilitate
61 // passing it to another thread.)
62 InterfaceHandle<ApplicationConnector> CreateApplicationConnector();
63
64 // Blocks until the |Application| is initialized (i.e., |Initialize()| is 57 // Blocks until the |Application| is initialized (i.e., |Initialize()| is
65 // received), if it is not already. 58 // received), if it is not already.
66 void WaitForInitialize(); 59 void WaitForInitialize();
67 60
68 // Unbinds the Shell and Application connections. Can be used to re-bind the 61 // Unbinds the Shell and Application connections. Can be used to re-bind the
69 // handles to another implementation of ApplicationImpl, for instance when 62 // handles to another implementation of ApplicationImpl, for instance when
70 // running apptests. 63 // running apptests.
71 void UnbindConnections(InterfaceRequest<Application>* application_request, 64 void UnbindConnections(InterfaceRequest<Application>* application_request,
72 ShellPtr* shell); 65 ShellPtr* shell);
73 66
74 // |Application| implementation. 67 // |Application| implementation.
75 void Initialize(InterfaceHandle<Shell> shell, 68 void Initialize(InterfaceHandle<Shell> shell,
76 Array<String> args, 69 Array<String> args,
77 const mojo::String& url) override; 70 const mojo::String& url) override;
78 void AcceptConnection(const String& requestor_url, 71 void AcceptConnection(const String& requestor_url,
79 InterfaceRequest<ServiceProvider> services, 72 InterfaceRequest<ServiceProvider> services,
80 InterfaceHandle<ServiceProvider> exposed_services, 73 InterfaceHandle<ServiceProvider> exposed_services,
81 const String& url) override; 74 const String& url) override;
82 void RequestQuit() override; 75 void RequestQuit() override;
83 76
84 private: 77 private:
85 std::vector<std::unique_ptr<ServiceProviderImpl>> service_provider_impls_; 78 std::vector<std::unique_ptr<ServiceProviderImpl>> service_provider_impls_;
86 ApplicationDelegate* delegate_; 79 ApplicationDelegate* delegate_;
87 Binding<Application> binding_; 80 Binding<Application> application_binding_;
88 ShellPtr shell_; 81 ShellPtr shell_;
89 std::string url_; 82 std::string url_;
90 std::vector<std::string> args_; 83 std::vector<std::string> args_;
91 84
92 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); 85 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl);
93 }; 86 };
94 87
95 } // namespace mojo 88 } // namespace mojo
96 89
97 #endif // MOJO_PUBLIC_CPP_APPLICATION_APPLICATION_IMPL_H_ 90 #endif // MOJO_PUBLIC_CPP_APPLICATION_APPLICATION_IMPL_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/application/BUILD.gn ('k') | mojo/public/cpp/application/application_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine