File: arc_service_launcher.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (141 lines) | stat: -rw-r--r-- 5,347 bytes parent folder | download | duplicates (5)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_ASH_ARC_SESSION_ARC_SERVICE_LAUNCHER_H_
#define CHROME_BROWSER_ASH_ARC_SESSION_ARC_SERVICE_LAUNCHER_H_

#include <memory>

#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observation.h"
#include "chrome/browser/ash/arc/session/arc_session_manager_observer.h"
#include "media/media_buildflags.h"

#if BUILDFLAG(USE_ARC_PROTECTED_MEDIA)
#include "chromeos/dbus/tpm_manager/tpm_manager.pb.h"
#endif  // BUILDFLAG(USE_ARC_PROTECTED_MEDIA)

class Profile;

namespace ash {
class SchedulerConfigurationManagerBase;
}

namespace arc {

class ArcDiskSpaceMonitor;
class ArcDlcInstaller;
class ArcIconCacheDelegateProvider;
class ArcLockedFullscreenManager;
class ArcPlayStoreEnabledPreferenceHandler;
class ArcServiceManager;
class ArcSessionManager;
class ArcSessionRunner;
class ArcVmDataMigrationNotifier;
class BrowserUrlOpener;

// Detects ARC availability and launches ARC bridge service.
class ArcServiceLauncher {
 public:
  // |scheduler_configuration_manager| must outlive |this| object.
  explicit ArcServiceLauncher(
      ash::SchedulerConfigurationManagerBase* scheduler_configuration_manager);

  ArcServiceLauncher(const ArcServiceLauncher&) = delete;
  ArcServiceLauncher& operator=(const ArcServiceLauncher&) = delete;

  ~ArcServiceLauncher();

  // Returns a global instance.
  static ArcServiceLauncher* Get();

  // Must be called early in startup.
  void Initialize();

  // Called just before most of BrowserContextKeyedService instance creation.
  // Set the given |profile| to ArcSessionManager, if the profile is allowed
  // to use ARC.
  void MaybeSetProfile(Profile* profile);

  // Called when the main profile is initialized after user logs in.
  void OnPrimaryUserProfilePrepared(Profile* profile);

  // Called after the main MessageLoop stops, and before the Profile is
  // destroyed.
  void Shutdown();

  // Resets internal state for testing. Specifically this needs to be
  // called if other profile needs to be used in the tests. In that case,
  // following this call, MaybeSetProfile() and
  // OnPrimaryUserProfilePrepared() should be called.
  void ResetForTesting();

  // Ensure all ARC keyed service factories are properly initialised.
  static void EnsureFactoriesBuilt();

  // Accessor for the locked fullscreen manager used by the caller to set up
  // or tear down ARC while entering or exiting locked fullscreen mode.
  ArcLockedFullscreenManager* arc_locked_fullscreen_manager() {
    return arc_locked_fullscreen_manager_.get();
  }

  // Specifies ArcSessionRunner to be passed into ArcSessionManager on its
  // creation. Must be called before ArcServiceLauncher is created,
  // and must not be called twice in a sequence.
  // On creating ArcServiceLauncher, the instance will be passed to
  // ArcSessionManager and it owns the instance. Otherwise, the specified
  // instance will be detected as leaked.
  static void SetArcSessionRunnerForTesting(
      std::unique_ptr<ArcSessionRunner> arc_session_runner);

 private:
#if BUILDFLAG(USE_ARC_PROTECTED_MEDIA)
  // Callback for when the CdmFactoryDaemon D-Bus service is available, also
  // used to trigger expanding the property files if a timeout occurs after we
  // detect TPM ownership.  The |from_timeout| parameter indicates if the call
  // came from the timeout case or from the D-Bus service availability case.
  void OnCdmFactoryDaemonAvailable(bool from_timeout,
                                   bool is_service_available);

  // Delayed callback for when we should check the TPM status.
  void OnCheckTpmStatus();

  // Callback used for checking if the TPM is owned yet.
  void OnGetTpmStatus(
      const ::tpm_manager::GetTpmNonsensitiveStatusReply& reply);

  // For tracking whether or not we have invoked property file expansion on the
  // session manager since this can happen via a timeout or callback.
  bool expanded_property_files_ = false;
#endif  // BUILDFLAG(USE_ARC_PROTECTED_MEDIA)

  // Callback invoked after the ARC DLC image has been bind-mounted
  // successfully. This function is called after OnPrepareArcDlc() has
  // successfully configured Upstart jobs and bind-mounted the DLC image.
  void OnDlcImageBindMountArcPath(bool result);

  std::unique_ptr<ArcServiceManager> arc_service_manager_;
  std::unique_ptr<ArcSessionManager> arc_session_manager_;
  std::unique_ptr<ArcPlayStoreEnabledPreferenceHandler>
      arc_play_store_enabled_preference_handler_;
  std::unique_ptr<ArcDiskSpaceMonitor> arc_disk_space_monitor_;
  std::unique_ptr<ArcIconCacheDelegateProvider>
      arc_icon_cache_delegate_provider_;
  std::unique_ptr<BrowserUrlOpener> arc_net_url_opener_;
  std::unique_ptr<ArcVmDataMigrationNotifier> arc_vm_data_migration_notifier_;
  std::unique_ptr<ArcLockedFullscreenManager> arc_locked_fullscreen_manager_;

  // |scheduler_configuration_manager_| outlives |this|.
  const raw_ptr<ash::SchedulerConfigurationManagerBase>
      scheduler_configuration_manager_;

  std::unique_ptr<ArcDlcInstaller> arc_dlc_installer_;

  base::WeakPtrFactory<ArcServiceLauncher> weak_factory_{this};
};

}  // namespace arc

#endif  // CHROME_BROWSER_ASH_ARC_SESSION_ARC_SERVICE_LAUNCHER_H_