in_process_dynamic_service_runner.h revision 5f1c94371a64b3196d4be9466099bb892df9b88e
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_IN_PROCESS_DYNAMIC_SERVICE_RUNNER_H_ 6#define MOJO_SHELL_IN_PROCESS_DYNAMIC_SERVICE_RUNNER_H_ 7 8#include "base/callback.h" 9#include "base/files/file_path.h" 10#include "base/macros.h" 11#include "base/scoped_native_library.h" 12#include "base/threading/simple_thread.h" 13#include "mojo/shell/dynamic_service_runner.h" 14#include "mojo/shell/keep_alive.h" 15 16namespace mojo { 17namespace shell { 18 19// An implementation of |DynamicServiceRunner| that loads/runs the given app 20// (from the file system) on a separate thread (in the current process). 21class InProcessDynamicServiceRunner 22 : public DynamicServiceRunner, 23 public base::DelegateSimpleThread::Delegate { 24 public: 25 explicit InProcessDynamicServiceRunner(Context* context); 26 virtual ~InProcessDynamicServiceRunner(); 27 28 // |DynamicServiceRunner| method: 29 virtual void Start(const base::FilePath& app_path, 30 ScopedMessagePipeHandle service_handle, 31 const base::Closure& app_completed_callback) OVERRIDE; 32 33 private: 34 // |base::DelegateSimpleThread::Delegate| method: 35 virtual void Run() OVERRIDE; 36 37 KeepAlive keep_alive_; 38 base::FilePath app_path_; 39 ScopedMessagePipeHandle service_handle_; 40 base::Callback<bool(void)> app_completed_callback_runner_; 41 42 base::ScopedNativeLibrary app_library_; 43 scoped_ptr<base::DelegateSimpleThread> thread_; 44 45 DISALLOW_COPY_AND_ASSIGN(InProcessDynamicServiceRunner); 46}; 47 48typedef DynamicServiceRunnerFactoryImpl<InProcessDynamicServiceRunner> 49 InProcessDynamicServiceRunnerFactory; 50 51} // namespace shell 52} // namespace mojo 53 54#endif // MOJO_SHELL_IN_PROCESS_DYNAMIC_SERVICE_RUNNER_H_ 55