1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 2a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// found in the LICENSE file. 4a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 5a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#ifndef MOJO_SHELL_OUT_OF_PROCESS_DYNAMIC_SERVICE_RUNNER_H_ 6a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#define MOJO_SHELL_OUT_OF_PROCESS_DYNAMIC_SERVICE_RUNNER_H_ 7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/callback.h" 9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/files/file_path.h" 10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "base/macros.h" 1123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)#include "mojo/shell/app_child_process.mojom.h" 12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "mojo/shell/app_child_process_host.h" 13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "mojo/shell/dynamic_service_runner.h" 14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace mojo { 16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)namespace shell { 17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 18effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch// An implementation of |DynamicServiceRunner| that loads/runs the given app 19effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch// (from the file system) in a separate process (of its own). 20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class OutOfProcessDynamicServiceRunner 21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) : public DynamicServiceRunner, 220de6073388f4e2780db8536178b129cd8f6ab386Torne (Richard Coles) public AppChildControllerClient { 23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) public: 24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) explicit OutOfProcessDynamicServiceRunner(Context* context); 25a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual ~OutOfProcessDynamicServiceRunner(); 26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // |DynamicServiceRunner| method: 28a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual void Start(const base::FilePath& app_path, 290de6073388f4e2780db8536178b129cd8f6ab386Torne (Richard Coles) ScopedMessagePipeHandle service_handle, 30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const base::Closure& app_completed_callback) OVERRIDE; 31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) private: 330de6073388f4e2780db8536178b129cd8f6ab386Torne (Richard Coles) // |AppChildControllerClient| method: 3423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) virtual void AppCompleted(int32_t result) OVERRIDE; 35a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 36a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) Context* const context_; 37a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 38a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::FilePath app_path_; 390de6073388f4e2780db8536178b129cd8f6ab386Torne (Richard Coles) ScopedMessagePipeHandle service_handle_; 40a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::Closure app_completed_callback_; 41a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 42a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) scoped_ptr<AppChildProcessHost> app_child_process_host_; 43a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 44a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(OutOfProcessDynamicServiceRunner); 45a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}; 46a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 47a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)typedef DynamicServiceRunnerFactoryImpl<OutOfProcessDynamicServiceRunner> 48a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) OutOfProcessDynamicServiceRunnerFactory; 49a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 50a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} // namespace shell 51a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} // namespace mojo 52a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 53a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#endif // MOJO_SHELL_OUT_OF_PROCESS_DYNAMIC_SERVICE_RUNNER_H_ 54