| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_RUNNER_CONTEXT_H_ | 5 #ifndef MOJO_SHELL_STANDALONE_CONTEXT_H_ |
| 6 #define MOJO_RUNNER_CONTEXT_H_ | 6 #define MOJO_SHELL_STANDALONE_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "mojo/runner/scoped_user_data_dir.h" | |
| 15 #include "mojo/runner/task_runners.h" | |
| 16 #include "mojo/runner/tracer.h" | |
| 17 #include "mojo/shell/application_manager.h" | 14 #include "mojo/shell/application_manager.h" |
| 15 #include "mojo/shell/standalone/scoped_user_data_dir.h" |
| 16 #include "mojo/shell/standalone/task_runners.h" |
| 17 #include "mojo/shell/standalone/tracer.h" |
| 18 #include "third_party/mojo/src/mojo/edk/embedder/process_delegate.h" | 18 #include "third_party/mojo/src/mojo/edk/embedder/process_delegate.h" |
| 19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
| 20 | 20 |
| 21 namespace mojo { | 21 namespace mojo { |
| 22 namespace shell { | 22 namespace shell { |
| 23 class NativeApplicationLoader; |
| 23 class PackageManagerImpl; | 24 class PackageManagerImpl; |
| 24 } | |
| 25 namespace runner { | |
| 26 | |
| 27 class NativeApplicationLoader; | |
| 28 | 25 |
| 29 // The "global" context for the shell's main process. | 26 // The "global" context for the shell's main process. |
| 30 // TODO(use_chrome_edk) | 27 // TODO(use_chrome_edk) |
| 31 //class Context : public edk::ProcessDelegate { | 28 // class Context : public edk::ProcessDelegate { |
| 32 class Context : public embedder::ProcessDelegate { | 29 class Context : public embedder::ProcessDelegate { |
| 33 public: | 30 public: |
| 34 Context(); | 31 Context(); |
| 35 ~Context() override; | 32 ~Context() override; |
| 36 | 33 |
| 37 static void EnsureEmbedderIsInitialized(); | 34 static void EnsureEmbedderIsInitialized(); |
| 38 | 35 |
| 39 // This must be called with a message loop set up for the current thread, | 36 // This must be called with a message loop set up for the current thread, |
| 40 // which must remain alive until after Shutdown() is called. Returns true on | 37 // which must remain alive until after Shutdown() is called. Returns true on |
| 41 // success. | 38 // success. |
| 42 bool Init(const base::FilePath& shell_file_root); | 39 bool Init(const base::FilePath& shell_file_root); |
| 43 | 40 |
| 44 // If Init() was called and succeeded, this must be called before destruction. | 41 // If Init() was called and succeeded, this must be called before destruction. |
| 45 void Shutdown(); | 42 void Shutdown(); |
| 46 | 43 |
| 47 // NOTE: call either Run() or RunCommandLineApplication(), but not both. | 44 // NOTE: call either Run() or RunCommandLineApplication(), but not both. |
| 48 | 45 |
| 49 // Runs the app specified by |url|. | 46 // Runs the app specified by |url|. |
| 50 void Run(const GURL& url); | 47 void Run(const GURL& url); |
| 51 | 48 |
| 52 // Run the application specified on the commandline. When the app finishes, | 49 // Run the application specified on the commandline. When the app finishes, |
| 53 // |callback| is run if not null, otherwise the message loop is quit. | 50 // |callback| is run if not null, otherwise the message loop is quit. |
| 54 void RunCommandLineApplication(const base::Closure& callback); | 51 void RunCommandLineApplication(const base::Closure& callback); |
| 55 | 52 |
| 56 TaskRunners* task_runners() { return task_runners_.get(); } | 53 TaskRunners* task_runners() { return task_runners_.get(); } |
| 57 shell::ApplicationManager* application_manager() { | 54 ApplicationManager* application_manager() { |
| 58 return application_manager_.get(); | 55 return application_manager_.get(); |
| 59 } | 56 } |
| 60 | 57 |
| 61 shell::PackageManagerImpl* package_manager() { return package_manager_; } | 58 PackageManagerImpl* package_manager() { return package_manager_; } |
| 62 | 59 |
| 63 private: | 60 private: |
| 64 class NativeViewportApplicationLoader; | 61 class NativeViewportApplicationLoader; |
| 65 | 62 |
| 66 // ProcessDelegate implementation. | 63 // ProcessDelegate implementation. |
| 67 void OnShutdownComplete() override; | 64 void OnShutdownComplete() override; |
| 68 | 65 |
| 69 void OnApplicationEnd(const GURL& url); | 66 void OnApplicationEnd(const GURL& url); |
| 70 | 67 |
| 71 ScopedUserDataDir scoped_user_data_dir; | 68 ScopedUserDataDir scoped_user_data_dir; |
| 72 std::set<GURL> app_urls_; | 69 std::set<GURL> app_urls_; |
| 73 scoped_ptr<TaskRunners> task_runners_; | 70 scoped_ptr<TaskRunners> task_runners_; |
| 74 // Ensure this is destructed before task_runners_ since it owns a message pipe | 71 // Ensure this is destructed before task_runners_ since it owns a message pipe |
| 75 // that needs the IO thread to destruct cleanly. | 72 // that needs the IO thread to destruct cleanly. |
| 76 Tracer tracer_; | 73 Tracer tracer_; |
| 77 // Owned by |application_manager_|. | 74 // Owned by |application_manager_|. |
| 78 shell::PackageManagerImpl* package_manager_; | 75 PackageManagerImpl* package_manager_; |
| 79 scoped_ptr<shell::ApplicationManager> application_manager_; | 76 scoped_ptr<ApplicationManager> application_manager_; |
| 80 base::Closure app_complete_callback_; | 77 base::Closure app_complete_callback_; |
| 81 base::Time main_entry_time_; | 78 base::Time main_entry_time_; |
| 82 | 79 |
| 83 DISALLOW_COPY_AND_ASSIGN(Context); | 80 DISALLOW_COPY_AND_ASSIGN(Context); |
| 84 }; | 81 }; |
| 85 | 82 |
| 86 } // namespace runner | 83 } // namespace shell |
| 87 } // namespace mojo | 84 } // namespace mojo |
| 88 | 85 |
| 89 #endif // MOJO_RUNNER_CONTEXT_H_ | 86 #endif // MOJO_SHELL_STANDALONE_CONTEXT_H_ |
| OLD | NEW |