cc: Make picture pile base thread safe.
[chromium-blink-merge.git] / mojo / shell / dynamic_service_runner.h
blobaa392f853097a47283e97f9b7dd43cc9274f6420
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.
5 #ifndef MOJO_SHELL_DYNAMIC_SERVICE_RUNNER_H_
6 #define MOJO_SHELL_DYNAMIC_SERVICE_RUNNER_H_
8 #include "base/callback_forward.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "mojo/public/cpp/system/core.h"
12 namespace base {
13 class FilePath;
16 namespace mojo {
17 namespace shell {
19 class Context;
21 // Abstraction for loading a service (from the file system) and running it (on
22 // another thread or in a separate process).
23 class DynamicServiceRunner {
24 public:
25 virtual ~DynamicServiceRunner() {}
27 // Takes ownership of the file at |app_path|. Loads the app in that file and
28 // runs it on some other thread/process. |app_completed_callback| is posted
29 // (to the thread on which |Start()| was called) after |MojoMain()| completes.
30 virtual void Start(const base::FilePath& app_path,
31 ScopedMessagePipeHandle service_handle,
32 const base::Closure& app_completed_callback) = 0;
35 class DynamicServiceRunnerFactory {
36 public:
37 virtual ~DynamicServiceRunnerFactory() {}
38 virtual scoped_ptr<DynamicServiceRunner> Create(Context* context) = 0;
41 // A generic factory.
42 template <class DynamicServiceRunnerImpl>
43 class DynamicServiceRunnerFactoryImpl : public DynamicServiceRunnerFactory {
44 public:
45 DynamicServiceRunnerFactoryImpl() {}
46 virtual ~DynamicServiceRunnerFactoryImpl() {}
47 virtual scoped_ptr<DynamicServiceRunner> Create(Context* context) override {
48 return scoped_ptr<DynamicServiceRunner>(
49 new DynamicServiceRunnerImpl(context));
53 } // namespace shell
54 } // namespace mojo
56 #endif // MOJO_SHELL_DYNAMIC_SERVICE_RUNNER_H_