| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MOJO_SHELL_RUNNER_HOST_IN_PROCESS_NATIVE_RUNNER_H_ | |
| 6 #define MOJO_SHELL_RUNNER_HOST_IN_PROCESS_NATIVE_RUNNER_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/files/file_path.h" | |
| 10 #include "base/macros.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/scoped_native_library.h" | |
| 13 #include "base/threading/simple_thread.h" | |
| 14 #include "mojo/shell/native_runner.h" | |
| 15 #include "mojo/shell/runner/host/native_application_support.h" | |
| 16 | |
| 17 namespace base { | |
| 18 class TaskRunner; | |
| 19 } | |
| 20 | |
| 21 namespace mojo { | |
| 22 namespace shell { | |
| 23 | |
| 24 // An implementation of |NativeRunner| that loads/runs the given app (from the | |
| 25 // file system) on a separate thread (in the current process). | |
| 26 class InProcessNativeRunner : public NativeRunner, | |
| 27 public base::DelegateSimpleThread::Delegate { | |
| 28 public: | |
| 29 InProcessNativeRunner(); | |
| 30 ~InProcessNativeRunner() override; | |
| 31 | |
| 32 // NativeRunner: | |
| 33 mojom::ShellClientPtr Start( | |
| 34 const base::FilePath& app_path, | |
| 35 const Identity& target, | |
| 36 bool start_sandboxed, | |
| 37 const base::Callback<void(base::ProcessId)>& pid_available_callback, | |
| 38 const base::Closure& app_completed_callback) override; | |
| 39 | |
| 40 private: | |
| 41 // |base::DelegateSimpleThread::Delegate| method: | |
| 42 void Run() override; | |
| 43 | |
| 44 base::FilePath app_path_; | |
| 45 InterfaceRequest<mojom::ShellClient> request_; | |
| 46 base::Callback<bool(void)> app_completed_callback_runner_; | |
| 47 | |
| 48 base::ScopedNativeLibrary app_library_; | |
| 49 scoped_ptr<base::DelegateSimpleThread> thread_; | |
| 50 | |
| 51 DISALLOW_COPY_AND_ASSIGN(InProcessNativeRunner); | |
| 52 }; | |
| 53 | |
| 54 class InProcessNativeRunnerFactory : public NativeRunnerFactory { | |
| 55 public: | |
| 56 explicit InProcessNativeRunnerFactory(base::TaskRunner* launch_process_runner) | |
| 57 : launch_process_runner_(launch_process_runner) {} | |
| 58 ~InProcessNativeRunnerFactory() override {} | |
| 59 | |
| 60 scoped_ptr<NativeRunner> Create(const base::FilePath& app_path) override; | |
| 61 | |
| 62 private: | |
| 63 base::TaskRunner* const launch_process_runner_; | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(InProcessNativeRunnerFactory); | |
| 66 }; | |
| 67 | |
| 68 } // namespace shell | |
| 69 } // namespace mojo | |
| 70 | |
| 71 #endif // MOJO_SHELL_RUNNER_HOST_IN_PROCESS_NATIVE_RUNNER_H_ | |
| OLD | NEW |