[Sync] Fix invalidations on Android.
[chromium-blink-merge.git] / mojo / shell / in_process_native_runner.h
bloba5639f4766b6f23327466d549bce54fac3e494e2
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 SHELL_IN_PROCESS_NATIVE_RUNNER_H_
6 #define SHELL_IN_PROCESS_NATIVE_RUNNER_H_
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/application_manager/native_runner.h"
15 #include "mojo/shell/native_application_support.h"
17 namespace mojo {
18 namespace shell {
20 class Context;
22 // An implementation of |NativeRunner| that loads/runs the given app (from the
23 // file system) on a separate thread (in the current process).
24 class InProcessNativeRunner : public NativeRunner,
25 public base::DelegateSimpleThread::Delegate {
26 public:
27 explicit InProcessNativeRunner(Context* context);
28 ~InProcessNativeRunner() override;
30 // |NativeRunner| method:
31 void Start(const base::FilePath& app_path,
32 NativeApplicationCleanup cleanup,
33 InterfaceRequest<Application> application_request,
34 const base::Closure& app_completed_callback) override;
36 private:
37 // |base::DelegateSimpleThread::Delegate| method:
38 void Run() override;
40 base::FilePath app_path_;
41 NativeApplicationCleanup cleanup_;
42 InterfaceRequest<Application> application_request_;
43 base::Callback<bool(void)> app_completed_callback_runner_;
45 base::ScopedNativeLibrary app_library_;
46 scoped_ptr<base::DelegateSimpleThread> thread_;
48 DISALLOW_COPY_AND_ASSIGN(InProcessNativeRunner);
51 class InProcessNativeRunnerFactory : public NativeRunnerFactory {
52 public:
53 explicit InProcessNativeRunnerFactory(Context* context) : context_(context) {}
54 ~InProcessNativeRunnerFactory() override {}
56 scoped_ptr<NativeRunner> Create(const Options& options) override;
58 private:
59 Context* const context_;
61 DISALLOW_COPY_AND_ASSIGN(InProcessNativeRunnerFactory);
64 } // namespace shell
65 } // namespace mojo
67 #endif // SHELL_IN_PROCESS_NATIVE_RUNNER_H_