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

Side by Side Diff: mojo/shell/public/cpp/application_runner.h

Issue 1801963002: Change primordial pipes to ShellClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase onto catalog CL Created 4 years, 9 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/native_runner.h ('k') | mojo/shell/public/cpp/connector.h » ('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 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_SHELL_PUBLIC_CPP_APPLICATION_RUNNER_H_ 5 #ifndef MOJO_SHELL_PUBLIC_CPP_APPLICATION_RUNNER_H_
6 #define MOJO_SHELL_PUBLIC_CPP_APPLICATION_RUNNER_H_ 6 #define MOJO_SHELL_PUBLIC_CPP_APPLICATION_RUNNER_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "mojo/public/cpp/system/core.h" 10 #include "mojo/public/cpp/system/core.h"
11 11
12 namespace mojo { 12 namespace mojo {
13 13
14 class ShellClient; 14 class ShellClient;
15 class ShellConnection; 15 class ShellConnection;
16 16
17 // A utility for running a chromium based mojo Application. The typical use 17 // A utility for running a chromium based mojo Application. The typical use
18 // case is to use when writing your MojoMain: 18 // case is to use when writing your MojoMain:
19 // 19 //
20 // MojoResult MojoMain(MojoHandle shell_handle) { 20 // MojoResult MojoMain(MojoHandle shell_handle) {
21 // mojo::ApplicationRunner runner(new MyDelegate()); 21 // mojo::ApplicationRunner runner(new MyDelegate());
22 // return runner.Run(shell_handle); 22 // return runner.Run(shell_handle);
23 // } 23 // }
24 // 24 //
25 // ApplicationRunner takes care of chromium environment initialization and 25 // ApplicationRunner takes care of chromium environment initialization and
26 // shutdown, and starting a MessageLoop from which your application can run and 26 // shutdown, and starting a MessageLoop from which your application can run and
27 // ultimately Quit(). 27 // ultimately Quit().
28 class ApplicationRunner { 28 class ApplicationRunner {
29 public: 29 public:
30 // Takes ownership of |delegate|. 30 // Takes ownership of |client|.
31 explicit ApplicationRunner(ShellClient* client); 31 explicit ApplicationRunner(ShellClient* client);
32 ~ApplicationRunner(); 32 ~ApplicationRunner();
33 33
34 static void InitBaseCommandLine(); 34 static void InitBaseCommandLine();
35 35
36 void set_message_loop_type(base::MessageLoop::Type type); 36 void set_message_loop_type(base::MessageLoop::Type type);
37 37
38 // Once the various parameters have been set above, use Run to initialize an 38 // Once the various parameters have been set above, use Run to initialize an
39 // ShellConnection wired to the provided delegate, and run a MessageLoop until 39 // ShellConnection wired to the provided delegate, and run a MessageLoop until
40 // the application exits. 40 // the application exits.
41 // 41 //
42 // Iff |init_base| is true, the runner will perform some initialization of 42 // Iff |init_base| is true, the runner will perform some initialization of
43 // base globals (e.g. CommandLine and AtExitManager) before starting the 43 // base globals (e.g. CommandLine and AtExitManager) before starting the
44 // application. 44 // application.
45 MojoResult Run(MojoHandle shell_handle, bool init_base); 45 MojoResult Run(MojoHandle shell_handle, bool init_base);
46 46
47 // Calls Run above with |init_base| set to |true|. 47 // Calls Run above with |init_base| set to |true|.
48 MojoResult Run(MojoHandle shell_handle); 48 MojoResult Run(MojoHandle shell_handle);
49 49
50 // Allows the caller to shut down the connection with the shell. After the 50 // Allows the caller to shut down the connection with the shell. After the
51 // shell notices the pipe has closed, it will no longer track an instance of 51 // shell notices the pipe has closed, it will no longer track an instance of
52 // this application, though this application may continue to run and service 52 // this application, though this application may continue to run and service
53 // requests from others. 53 // requests from others.
54 void DestroyShellConnection(); 54 void DestroyShellConnection();
55 55
56 // Allows the caller to explicitly quit the application. Must be called from
57 // the thread which created the ApplicationRunner.
58 void Quit();
59
56 private: 60 private:
57 scoped_ptr<ShellConnection> connection_; 61 scoped_ptr<ShellConnection> connection_;
58 scoped_ptr<ShellClient> client_; 62 scoped_ptr<ShellClient> client_;
59 63
60 // MessageLoop type. TYPE_CUSTOM is default (MessagePumpMojo will be used as 64 // MessageLoop type. TYPE_CUSTOM is default (MessagePumpMojo will be used as
61 // the underlying message pump). 65 // the underlying message pump).
62 base::MessageLoop::Type message_loop_type_; 66 base::MessageLoop::Type message_loop_type_;
63 // Whether Run() has been called. 67 // Whether Run() has been called.
64 bool has_run_; 68 bool has_run_;
65 69
66 DISALLOW_COPY_AND_ASSIGN(ApplicationRunner); 70 DISALLOW_COPY_AND_ASSIGN(ApplicationRunner);
67 }; 71 };
68 72
69 } // namespace mojo 73 } // namespace mojo
70 74
71 #endif // MOJO_SHELL_PUBLIC_CPP_APPLICATION_RUNNER_H_ 75 #endif // MOJO_SHELL_PUBLIC_CPP_APPLICATION_RUNNER_H_
OLDNEW
« no previous file with comments | « mojo/shell/native_runner.h ('k') | mojo/shell/public/cpp/connector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698