Leo Lai | 16dea87 | 2019-12-06 10:39:21 +0800 | [diff] [blame] | 1 | // 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 Frysinger | c2c3289 | 2017-11-23 14:57:39 -0500 | [diff] [blame] | 4 | |
| 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 | |
| 12 | namespace webservd { |
| 13 | |
| 14 | class ProtocolHandler; |
Alex Vakulenko | 4168f8b | 2015-09-18 13:41:58 -0700 | [diff] [blame] | 15 | class TempFileManager; |
Mike Frysinger | c2c3289 | 2017-11-23 14:57:39 -0500 | [diff] [blame] | 16 | |
| 17 | // An abstract interface to expose Server object to IPC transport layer such as |
| 18 | // D-Bus. |
| 19 | class ServerInterface { |
| 20 | public: |
| 21 | ServerInterface() = default; |
Qijiang Fan | 6bc59e1 | 2020-11-11 02:51:06 +0900 | [diff] [blame] | 22 | ServerInterface(const ServerInterface&) = delete; |
| 23 | ServerInterface& operator=(const ServerInterface&) = delete; |
Mike Frysinger | c2c3289 | 2017-11-23 14:57:39 -0500 | [diff] [blame] | 24 | |
| 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 Vakulenko | 4168f8b | 2015-09-18 13:41:58 -0700 | [diff] [blame] | 33 | // 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 Frysinger | c2c3289 | 2017-11-23 14:57:39 -0500 | [diff] [blame] | 38 | 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 Frysinger | c2c3289 | 2017-11-23 14:57:39 -0500 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | } // namespace webservd |
| 50 | |
| 51 | #endif // WEBSERVER_WEBSERVD_SERVER_INTERFACE_H_ |