Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: services/service_manager/standalone/context.h

Issue 2651953002: Revert of [Service Manager] Get rid of dynamic service discovery (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_SERVICE_MANAGER_STANDALONE_CONTEXT_H_ 5 #ifndef SERVICES_SERVICE_MANAGER_STANDALONE_CONTEXT_H_
6 #define SERVICES_SERVICE_MANAGER_STANDALONE_CONTEXT_H_ 6 #define SERVICES_SERVICE_MANAGER_STANDALONE_CONTEXT_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback_forward.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/threading/thread.h"
12 #include "base/time/time.h" 14 #include "base/time/time.h"
13 #include "base/values.h" 15 #include "base/values.h"
14 #include "services/service_manager/runner/host/service_process_launcher.h" 16 #include "services/service_manager/runner/host/service_process_launcher.h"
17 #include "services/service_manager/service_manager.h"
15 #include "services/service_manager/standalone/tracer.h" 18 #include "services/service_manager/standalone/tracer.h"
16 #include "services/tracing/public/cpp/provider.h" 19 #include "services/tracing/public/cpp/provider.h"
17 20
18 namespace base { 21 namespace base {
19 class Value; 22 class SingleThreadTaskRunner;
20 } 23 }
21 24
22 namespace catalog { 25 namespace catalog {
23 class Catalog; 26 class Catalog;
24 } 27 }
25 28
26 namespace service_manager { 29 namespace service_manager {
27 30
28 class ServiceManager;
29
30 constexpr size_t kThreadPoolMaxThreads = 3; 31 constexpr size_t kThreadPoolMaxThreads = 3;
31 32
32 // The "global" context for the service manager's main process. 33 // The "global" context for the service manager's main process.
33 class Context { 34 class Context {
34 public: 35 public:
35 Context(ServiceProcessLauncher::Delegate* launcher_delegate, 36 struct InitParams {
36 std::unique_ptr<base::Value> catalog_content); 37 InitParams();
38 ~InitParams();
39
40 ServiceProcessLauncher::Delegate*
41 service_process_launcher_delegate = nullptr;
42 std::unique_ptr<base::Value> static_catalog;
43 // If true the edk is initialized.
44 bool init_edk = true;
45 };
46
47 Context();
37 ~Context(); 48 ~Context();
38 49
50 static void EnsureEmbedderIsInitialized();
51
52 // This must be called with a message loop set up for the current thread,
53 // which must remain alive until after Shutdown() is called.
54 void Init(std::unique_ptr<InitParams> init_params);
55
56 // If Init() was called and succeeded, this must be called before destruction.
57 void Shutdown();
58
39 // Run the application specified on the command line. 59 // Run the application specified on the command line.
40 void RunCommandLineApplication(); 60 void RunCommandLineApplication();
41 61
42 ServiceManager* service_manager() { return service_manager_.get(); } 62 ServiceManager* service_manager() { return service_manager_.get(); }
43 63
44 private: 64 private:
65 void OnShutdownComplete();
66
45 // Runs the app specified by |name|. 67 // Runs the app specified by |name|.
46 void Run(const std::string& name); 68 void Run(const std::string& name);
47 69
70 scoped_refptr<base::SingleThreadTaskRunner> service_manager_runner_;
71 std::unique_ptr<base::Thread> io_thread_;
48 scoped_refptr<base::SequencedWorkerPool> blocking_pool_; 72 scoped_refptr<base::SequencedWorkerPool> blocking_pool_;
49 73
74 // Ensure this is destructed before task_runners_ since it owns a message pipe
75 // that needs the IO thread to destruct cleanly.
50 Tracer tracer_; 76 Tracer tracer_;
51 tracing::Provider provider_; 77 tracing::Provider provider_;
52 std::unique_ptr<catalog::Catalog> catalog_; 78 std::unique_ptr<catalog::Catalog> catalog_;
53 std::unique_ptr<ServiceManager> service_manager_; 79 std::unique_ptr<ServiceManager> service_manager_;
54 base::Time main_entry_time_; 80 base::Time main_entry_time_;
81 bool init_edk_ = false;
55 82
56 DISALLOW_COPY_AND_ASSIGN(Context); 83 DISALLOW_COPY_AND_ASSIGN(Context);
57 }; 84 };
58 85
59 } // namespace service_manager 86 } // namespace service_manager
60 87
61 #endif // SERVICES_SERVICE_MANAGER_STANDALONE_CONTEXT_H_ 88 #endif // SERVICES_SERVICE_MANAGER_STANDALONE_CONTEXT_H_
OLDNEW
« no previous file with comments | « services/service_manager/service_manager.cc ('k') | services/service_manager/standalone/context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698