OLD | NEW |
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> |
(...skipping 26 matching lines...) Expand all Loading... |
37 ApplicationImpl(ApplicationDelegate* delegate, | 37 ApplicationImpl(ApplicationDelegate* delegate, |
38 InterfaceRequest<Application> request); | 38 InterfaceRequest<Application> request); |
39 ~ApplicationImpl() override; | 39 ~ApplicationImpl() override; |
40 | 40 |
41 // Quits the main run loop for this application. | 41 // Quits the main run loop for this application. |
42 // TODO(vtl): This is implemented in application_runner.cc (for example). Its | 42 // TODO(vtl): This is implemented in application_runner.cc (for example). Its |
43 // presence here is pretty dubious. | 43 // presence here is pretty dubious. |
44 static void Terminate(); | 44 static void Terminate(); |
45 | 45 |
46 // The Mojo shell. This will return a valid pointer after Initialize() has | 46 // The Mojo shell. This will return a valid pointer after Initialize() has |
47 // been invoked. It will remain valid until UnbindConnections() is invoked or | 47 // been invoked. It will remain valid until this object is destroyed. |
48 // the ApplicationImpl is destroyed. | |
49 Shell* shell() const { return shell_.get(); } | 48 Shell* shell() const { return shell_.get(); } |
50 | 49 |
51 const std::string& url() const { return url_; } | 50 const std::string& url() const { return url_; } |
52 | 51 |
53 // Returns any initial configuration arguments, passed by the Shell. | 52 // Returns any initial configuration arguments, passed by the Shell. |
54 const std::vector<std::string>& args() const { return args_; } | 53 const std::vector<std::string>& args() const { return args_; } |
55 bool HasArg(const std::string& arg) const; | 54 bool HasArg(const std::string& arg) const; |
56 | 55 |
57 // Blocks until the |Application| is initialized (i.e., |Initialize()| is | 56 private: |
58 // received), if it is not already. | |
59 void WaitForInitialize(); | |
60 | |
61 // Unbinds the Shell and Application connections. Can be used to re-bind the | |
62 // handles to another implementation of ApplicationImpl, for instance when | |
63 // running apptests. | |
64 void UnbindConnections(InterfaceRequest<Application>* application_request, | |
65 ShellPtr* shell); | |
66 | |
67 // |Application| implementation. | 57 // |Application| implementation. |
68 void Initialize(InterfaceHandle<Shell> shell, | 58 void Initialize(InterfaceHandle<Shell> shell, |
69 Array<String> args, | 59 Array<String> args, |
70 const mojo::String& url) override; | 60 const mojo::String& url) override; |
71 void AcceptConnection(const String& requestor_url, | 61 void AcceptConnection(const String& requestor_url, |
72 InterfaceRequest<ServiceProvider> services, | 62 InterfaceRequest<ServiceProvider> services, |
73 InterfaceHandle<ServiceProvider> exposed_services, | 63 InterfaceHandle<ServiceProvider> exposed_services, |
74 const String& url) override; | 64 const String& url) override; |
75 void RequestQuit() override; | 65 void RequestQuit() override; |
76 | 66 |
77 private: | |
78 std::vector<std::unique_ptr<ServiceProviderImpl>> service_provider_impls_; | 67 std::vector<std::unique_ptr<ServiceProviderImpl>> service_provider_impls_; |
79 ApplicationDelegate* delegate_; | 68 ApplicationDelegate* delegate_; |
80 Binding<Application> application_binding_; | 69 Binding<Application> application_binding_; |
81 ShellPtr shell_; | 70 ShellPtr shell_; |
82 std::string url_; | 71 std::string url_; |
83 std::vector<std::string> args_; | 72 std::vector<std::string> args_; |
84 | 73 |
85 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); | 74 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); |
86 }; | 75 }; |
87 | 76 |
88 } // namespace mojo | 77 } // namespace mojo |
89 | 78 |
90 #endif // MOJO_PUBLIC_CPP_APPLICATION_APPLICATION_IMPL_H_ | 79 #endif // MOJO_PUBLIC_CPP_APPLICATION_APPLICATION_IMPL_H_ |
OLD | NEW |