summaryrefslogtreecommitdiff
path: root/chromium/services/service_manager/standalone/context.h
blob: 5e93ee2570d9b883706a6614b8748c0259533505 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SERVICES_SERVICE_MANAGER_STANDALONE_CONTEXT_H_
#define SERVICES_SERVICE_MANAGER_STANDALONE_CONTEXT_H_

#include <memory>

#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/time/time.h"
#include "base/values.h"
#include "services/service_manager/runner/host/service_process_launcher.h"
#include "services/service_manager/standalone/tracer.h"
#include "services/tracing/public/cpp/provider.h"

namespace base {
class SequencedWorkerPool;
class Value;
}

namespace catalog {
class Catalog;
}

namespace service_manager {

class ServiceManager;

constexpr size_t kThreadPoolMaxThreads = 3;

// The "global" context for the service manager's main process.
class Context {
 public:
  Context(ServiceProcessLauncher::Delegate* launcher_delegate,
          std::unique_ptr<base::Value> catalog_content);
  ~Context();

  // Run the application specified on the command line.
  void RunCommandLineApplication();

  ServiceManager* service_manager() { return service_manager_.get(); }

 private:
  // Runs the app specified by |name|.
  void Run(const std::string& name);

  scoped_refptr<base::SequencedWorkerPool> blocking_pool_;

  Tracer tracer_;
  tracing::Provider provider_;
  std::unique_ptr<catalog::Catalog> catalog_;
  std::unique_ptr<ServiceManager> service_manager_;
  base::Time main_entry_time_;

  DISALLOW_COPY_AND_ASSIGN(Context);
};

}  // namespace service_manager

#endif  // SERVICES_SERVICE_MANAGER_STANDALONE_CONTEXT_H_