blob: 0c26c360d9580ad64f7b886aa00159abbe838864 [file] [log] [blame]
Leo Lai16dea872019-12-06 10:39:21 +08001// Copyright 2015 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Mike Frysingerc2c32892017-11-23 14:57:39 -05004
5#ifndef WEBSERVER_WEBSERVD_SERVER_INTERFACE_H_
6#define WEBSERVER_WEBSERVD_SERVER_INTERFACE_H_
7
8#include <base/macros.h>
9
10#include "webservd/config.h"
11
12namespace webservd {
13
14class ProtocolHandler;
Alex Vakulenko4168f8b2015-09-18 13:41:58 -070015class TempFileManager;
Mike Frysingerc2c32892017-11-23 14:57:39 -050016
17// An abstract interface to expose Server object to IPC transport layer such as
18// D-Bus.
19class ServerInterface {
20 public:
21 ServerInterface() = default;
Qijiang Fan6bc59e12020-11-11 02:51:06 +090022 ServerInterface(const ServerInterface&) = delete;
23 ServerInterface& operator=(const ServerInterface&) = delete;
Mike Frysingerc2c32892017-11-23 14:57:39 -050024
25 // Called by ProtocolHandler to notify the server that a new protocol handler
26 // appears online or goes offline.
27 virtual void ProtocolHandlerStarted(ProtocolHandler* handler) = 0;
28 virtual void ProtocolHandlerStopped(ProtocolHandler* handler) = 0;
29
30 // Returns the server configuration data.
31 virtual const Config& GetConfig() const = 0;
32
Alex Vakulenko4168f8b2015-09-18 13:41:58 -070033 // Returns the temp file manager used to track life-times of temporary files.
34 // The returned pointer is still owned by the server, so it must not be
35 // stored or deleted.
36 virtual TempFileManager* GetTempFileManager() = 0;
37
Mike Frysingerc2c32892017-11-23 14:57:39 -050038 protected:
39 // This interface should not be used to control the life-time of the class
40 // that derives from this interface. This is especially important when a mock
41 // server class is used. Since the life-time of the mock must be controlled
42 // by the test itself, we can't let some business logic suddenly delete
43 // the instance of this interface.
44 // So, just declare the destructor as protected, so nobody can just call
45 // delete on a pointer to ServerInterface.
46 ~ServerInterface() = default;
Mike Frysingerc2c32892017-11-23 14:57:39 -050047};
48
49} // namespace webservd
50
51#endif // WEBSERVER_WEBSERVD_SERVER_INTERFACE_H_