OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef SERVICES_SHELL_STANDALONE_CONTEXT_H_ | 5 #ifndef SERVICES_SHELL_STANDALONE_CONTEXT_H_ |
6 #define SERVICES_SHELL_STANDALONE_CONTEXT_H_ | 6 #define SERVICES_SHELL_STANDALONE_CONTEXT_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "mojo/edk/embedder/process_delegate.h" | 15 #include "mojo/edk/embedder/process_delegate.h" |
15 #include "services/shell/shell.h" | 16 #include "services/shell/shell.h" |
16 #include "services/shell/standalone/tracer.h" | 17 #include "services/shell/standalone/tracer.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 class SingleThreadTaskRunner; | 20 class SingleThreadTaskRunner; |
20 } | 21 } |
21 | 22 |
22 namespace catalog { | 23 namespace catalog { |
23 class Factory; | 24 class Factory; |
24 class Store; | 25 class Store; |
25 } | 26 } |
26 | 27 |
27 namespace mojo { | |
28 namespace shell { | 28 namespace shell { |
29 class NativeRunnerDelegate; | 29 class NativeRunnerDelegate; |
30 | 30 |
31 // The "global" context for the shell's main process. | 31 // The "global" context for the shell's main process. |
32 class Context : public edk::ProcessDelegate { | 32 class Context : public mojo::edk::ProcessDelegate { |
33 public: | 33 public: |
34 struct InitParams { | 34 struct InitParams { |
35 InitParams(); | 35 InitParams(); |
36 ~InitParams(); | 36 ~InitParams(); |
37 | 37 |
38 NativeRunnerDelegate* native_runner_delegate = nullptr; | 38 NativeRunnerDelegate* native_runner_delegate = nullptr; |
39 scoped_ptr<catalog::Store> catalog_store; | 39 std::unique_ptr<catalog::Store> catalog_store; |
40 // If true the edk is initialized. | 40 // If true the edk is initialized. |
41 bool init_edk = true; | 41 bool init_edk = true; |
42 }; | 42 }; |
43 | 43 |
44 Context(); | 44 Context(); |
45 ~Context() override; | 45 ~Context() override; |
46 | 46 |
47 static void EnsureEmbedderIsInitialized(); | 47 static void EnsureEmbedderIsInitialized(); |
48 | 48 |
49 // This must be called with a message loop set up for the current thread, | 49 // This must be called with a message loop set up for the current thread, |
50 // which must remain alive until after Shutdown() is called. | 50 // which must remain alive until after Shutdown() is called. |
51 void Init(scoped_ptr<InitParams> init_params); | 51 void Init(std::unique_ptr<InitParams> init_params); |
52 | 52 |
53 // If Init() was called and succeeded, this must be called before destruction. | 53 // If Init() was called and succeeded, this must be called before destruction. |
54 void Shutdown(); | 54 void Shutdown(); |
55 | 55 |
56 // Run the application specified on the command line. | 56 // Run the application specified on the command line. |
57 void RunCommandLineApplication(); | 57 void RunCommandLineApplication(); |
58 | 58 |
59 Shell* shell() { return shell_.get(); } | 59 Shell* shell() { return shell_.get(); } |
60 | 60 |
61 private: | 61 private: |
62 // edk::ProcessDelegate: | 62 // mojo::edk::ProcessDelegate: |
63 void OnShutdownComplete() override; | 63 void OnShutdownComplete() override; |
64 | 64 |
65 // Runs the app specified by |name|. | 65 // Runs the app specified by |name|. |
66 void Run(const std::string& name); | 66 void Run(const std::string& name); |
67 | 67 |
68 scoped_refptr<base::SingleThreadTaskRunner> shell_runner_; | 68 scoped_refptr<base::SingleThreadTaskRunner> shell_runner_; |
69 scoped_ptr<base::Thread> io_thread_; | 69 std::unique_ptr<base::Thread> io_thread_; |
70 scoped_refptr<base::SequencedWorkerPool> blocking_pool_; | 70 scoped_refptr<base::SequencedWorkerPool> blocking_pool_; |
71 | 71 |
72 // Ensure this is destructed before task_runners_ since it owns a message pipe | 72 // Ensure this is destructed before task_runners_ since it owns a message pipe |
73 // that needs the IO thread to destruct cleanly. | 73 // that needs the IO thread to destruct cleanly. |
74 Tracer tracer_; | 74 Tracer tracer_; |
75 scoped_ptr<catalog::Factory> catalog_; | 75 std::unique_ptr<catalog::Factory> catalog_; |
76 scoped_ptr<Shell> shell_; | 76 std::unique_ptr<Shell> shell_; |
77 base::Time main_entry_time_; | 77 base::Time main_entry_time_; |
78 bool init_edk_ = false; | 78 bool init_edk_ = false; |
79 | 79 |
80 DISALLOW_COPY_AND_ASSIGN(Context); | 80 DISALLOW_COPY_AND_ASSIGN(Context); |
81 }; | 81 }; |
82 | 82 |
83 } // namespace shell | 83 } // namespace shell |
84 } // namespace mojo | |
85 | 84 |
86 #endif // SERVICES_SHELL_STANDALONE_CONTEXT_H_ | 85 #endif // SERVICES_SHELL_STANDALONE_CONTEXT_H_ |
OLD | NEW |