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

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

Issue 668663006: Standardize usage of virtual/override/final in mojo/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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_PUBLIC_APPLICATION_APPLICATION_IMPL_H_ 5 #ifndef MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_
6 #define MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_ 6 #define MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_
7 #include <vector> 7 #include <vector>
8 8
9 #include "mojo/public/cpp/application/application_connection.h" 9 #include "mojo/public/cpp/application/application_connection.h"
10 #include "mojo/public/cpp/application/lib/service_connector.h" 10 #include "mojo/public/cpp/application/lib/service_connector.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // 48 //
49 // BarContext context; 49 // BarContext context;
50 // app.AddService<BarImpl>(&context); 50 // app.AddService<BarImpl>(&context);
51 // 51 //
52 // 52 //
53 class ApplicationImpl : public InterfaceImpl<Application> { 53 class ApplicationImpl : public InterfaceImpl<Application> {
54 public: 54 public:
55 ApplicationImpl(ApplicationDelegate* delegate, 55 ApplicationImpl(ApplicationDelegate* delegate,
56 ScopedMessagePipeHandle shell_handle); 56 ScopedMessagePipeHandle shell_handle);
57 ApplicationImpl(ApplicationDelegate* delegate, MojoHandle shell_handle); 57 ApplicationImpl(ApplicationDelegate* delegate, MojoHandle shell_handle);
58 virtual ~ApplicationImpl(); 58 ~ApplicationImpl() override;
59 59
60 Shell* shell() const { return shell_.get(); } 60 Shell* shell() const { return shell_.get(); }
61 61
62 // Returns any initial configuration arguments, passed by the Shell. 62 // Returns any initial configuration arguments, passed by the Shell.
63 const std::vector<std::string>& args() const { return args_; } 63 const std::vector<std::string>& args() const { return args_; }
64 64
65 // Establishes a new connection to an application. Caller does not own. 65 // Establishes a new connection to an application. Caller does not own.
66 ApplicationConnection* ConnectToApplication(const String& application_url); 66 ApplicationConnection* ConnectToApplication(const String& application_url);
67 67
68 // Connect to application identified by |application_url| and connect to the 68 // Connect to application identified by |application_url| and connect to the
69 // service implementation of the interface identified by |Interface|. 69 // service implementation of the interface identified by |Interface|.
70 template <typename Interface> 70 template <typename Interface>
71 void ConnectToService(const std::string& application_url, 71 void ConnectToService(const std::string& application_url,
72 InterfacePtr<Interface>* ptr) { 72 InterfacePtr<Interface>* ptr) {
73 ConnectToApplication(application_url)->ConnectToService(ptr); 73 ConnectToApplication(application_url)->ConnectToService(ptr);
74 } 74 }
75 75
76 // Wait for the ShellPtr's Initialize message. 76 // Wait for the ShellPtr's Initialize message.
77 bool WaitForInitialize(); 77 bool WaitForInitialize();
78 78
79 // Unbind the shell from this application and return its handle. 79 // Unbind the shell from this application and return its handle.
80 ScopedMessagePipeHandle UnbindShell(); 80 ScopedMessagePipeHandle UnbindShell();
81 81
82 // Application implementation. 82 // Application implementation.
83 virtual void Initialize(Array<String> args) override; 83 void Initialize(Array<String> args) override;
84 84
85 private: 85 private:
86 class ShellPtrWatcher; 86 class ShellPtrWatcher;
87 87
88 void BindShell(ScopedMessagePipeHandle shell_handle); 88 void BindShell(ScopedMessagePipeHandle shell_handle);
89 void ClearConnections(); 89 void ClearConnections();
90 void OnShellError() { 90 void OnShellError() {
91 ClearConnections(); 91 ClearConnections();
92 Terminate(); 92 Terminate();
93 }; 93 };
94 94
95 // Quits the main run loop for this application. 95 // Quits the main run loop for this application.
96 static void Terminate(); 96 static void Terminate();
97 97
98 // Application implementation. 98 // Application implementation.
99 virtual void AcceptConnection(const String& requestor_url, 99 void AcceptConnection(const String& requestor_url,
100 ServiceProviderPtr provider) override; 100 ServiceProviderPtr provider) override;
101 101
102 typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList; 102 typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList;
103 103
104 bool initialized_; 104 bool initialized_;
105 ServiceRegistryList incoming_service_registries_; 105 ServiceRegistryList incoming_service_registries_;
106 ServiceRegistryList outgoing_service_registries_; 106 ServiceRegistryList outgoing_service_registries_;
107 ApplicationDelegate* delegate_; 107 ApplicationDelegate* delegate_;
108 ShellPtr shell_; 108 ShellPtr shell_;
109 ShellPtrWatcher* shell_watch_; 109 ShellPtrWatcher* shell_watch_;
110 std::vector<std::string> args_; 110 std::vector<std::string> args_;
111 111
112 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); 112 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl);
113 }; 113 };
114 114
115 } // namespace mojo 115 } // namespace mojo
116 116
117 #endif // MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_ 117 #endif // MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_
OLDNEW
« no previous file with comments | « mojo/public/c/system/tests/core_perftest.cc ('k') | mojo/public/cpp/application/lib/application_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698