forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcups_proxy_service.h
61 lines (45 loc) · 1.86 KB
/
cups_proxy_service.h
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
// Copyright 2019 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_SERVICES_CUPS_PROXY_CUPS_PROXY_SERVICE_H_
#define CHROME_SERVICES_CUPS_PROXY_CUPS_PROXY_SERVICE_H_
#include <memory>
#include "base/memory/weak_ptr.h"
#include "base/no_destructor.h"
#include "base/observer_list_types.h"
#include "chrome/services/cups_proxy/public/mojom/proxy.mojom.h"
namespace cups_proxy {
class CupsProxyServiceDelegate;
class ProxyManager;
// This service lives in the browser process and is managed by the
// CupsProxyServiceManager. It bootstraps/maintains a mojom connection with the
// CupsProxyDaemon.
//
// Note: There is no method granting a service handle since beyond creation,
// this service's only client is the daemon, who's connection is managed
// internally.
class CupsProxyService {
public:
CupsProxyService(const CupsProxyService&) = delete;
CupsProxyService& operator=(const CupsProxyService&) = delete;
// Spawns the global service instance.
static void Spawn(std::unique_ptr<CupsProxyServiceDelegate> delegate);
// Shuts down the global service instance.
static void Shutdown();
private:
friend base::NoDestructor<CupsProxyService>;
CupsProxyService();
~CupsProxyService();
// Records whether we've attempted connection with the daemon yet.
bool bootstrap_attempted_ = false;
// Methods for connecting with the CupsProxyDaemon.
void BindToCupsProxyDaemon(
std::unique_ptr<CupsProxyServiceDelegate> delegate);
void OnBindToCupsProxyDaemon(bool success);
void ShutdownImpl();
// Handler that implements the top-level mojom interface (mojom::CupsProxier)
std::unique_ptr<ProxyManager> proxy_manager_;
base::WeakPtrFactory<CupsProxyService> weak_factory_{this};
};
} // namespace cups_proxy
#endif // CHROME_SERVICES_CUPS_PROXY_CUPS_PROXY_SERVICE_H_