1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MOJO_RUNNER_CONTEXT_H_
6 #define MOJO_RUNNER_CONTEXT_H_
11 #include "base/callback_forward.h"
12 #include "base/macros.h"
13 #include "base/time/time.h"
14 #include "mojo/edk/embedder/process_delegate.h"
15 #include "mojo/runner/scoped_user_data_dir.h"
16 #include "mojo/runner/task_runners.h"
17 #include "mojo/shell/application_manager.h"
21 namespace package_manager
{
22 class PackageManagerImpl
;
26 class NativeApplicationLoader
;
28 // The "global" context for the shell's main process.
29 class Context
: public embedder::ProcessDelegate
{
31 explicit Context(const base::FilePath
& shell_file_root
);
34 static void EnsureEmbedderIsInitialized();
36 // This must be called with a message loop set up for the current thread,
37 // which must remain alive until after Shutdown() is called. Returns true on
41 // If Init() was called and succeeded, this must be called before destruction.
44 // NOTE: call either Run() or RunCommandLineApplication(), but not both.
46 // Runs the app specified by |url|.
47 void Run(const GURL
& url
);
49 // Run the application specified on the commandline. When the app finishes,
50 // |callback| is run if not null, otherwise the message loop is quit.
51 void RunCommandLineApplication(const base::Closure
& callback
);
53 TaskRunners
* task_runners() { return task_runners_
.get(); }
54 shell::ApplicationManager
* application_manager() {
55 return application_manager_
.get();
58 package_manager::PackageManagerImpl
* package_manager() {
59 return package_manager_
;
63 class NativeViewportApplicationLoader
;
65 // ProcessDelegate implementation.
66 void OnShutdownComplete() override
;
68 void OnApplicationEnd(const GURL
& url
);
70 ScopedUserDataDir scoped_user_data_dir
;
71 std::set
<GURL
> app_urls_
;
72 scoped_ptr
<TaskRunners
> task_runners_
;
73 base::FilePath shell_file_root_
;
74 // Owned by |application_manager_|.
75 package_manager::PackageManagerImpl
* package_manager_
;
76 scoped_ptr
<shell::ApplicationManager
> application_manager_
;
77 base::Closure app_complete_callback_
;
78 base::Time main_entry_time_
;
80 DISALLOW_COPY_AND_ASSIGN(Context
);
86 #endif // MOJO_RUNNER_CONTEXT_H_