xref: /aosp_15_r20/external/openscreen/discovery/common/reporting_client.h (revision 3f982cf4871df8771c9d4abe6e9a6f8d829b2736)
1*3f982cf4SFabien Sanglard // Copyright 2020 The Chromium Authors. All rights reserved.
2*3f982cf4SFabien Sanglard // Use of this source code is governed by a BSD-style license that can be
3*3f982cf4SFabien Sanglard // found in the LICENSE file.
4*3f982cf4SFabien Sanglard 
5*3f982cf4SFabien Sanglard #ifndef DISCOVERY_COMMON_REPORTING_CLIENT_H_
6*3f982cf4SFabien Sanglard #define DISCOVERY_COMMON_REPORTING_CLIENT_H_
7*3f982cf4SFabien Sanglard 
8*3f982cf4SFabien Sanglard #include "platform/base/error.h"
9*3f982cf4SFabien Sanglard 
10*3f982cf4SFabien Sanglard namespace openscreen {
11*3f982cf4SFabien Sanglard namespace discovery {
12*3f982cf4SFabien Sanglard 
13*3f982cf4SFabien Sanglard // This class is implemented by the embedder who wishes to use discovery. The
14*3f982cf4SFabien Sanglard // discovery implementation will use this API to report back errors and metrics.
15*3f982cf4SFabien Sanglard // NOTE: All methods in the reporting client will be called from the task runner
16*3f982cf4SFabien Sanglard // thread.
17*3f982cf4SFabien Sanglard // TODO(rwkeane): Report state changes back to the caller.
18*3f982cf4SFabien Sanglard class ReportingClient {
19*3f982cf4SFabien Sanglard  public:
20*3f982cf4SFabien Sanglard   virtual ~ReportingClient() = default;
21*3f982cf4SFabien Sanglard 
22*3f982cf4SFabien Sanglard   // This method is called when an error is detected by the underlying
23*3f982cf4SFabien Sanglard   // infrastructure from which recovery cannot be initiated. For example, an
24*3f982cf4SFabien Sanglard   // error binding a multicast socket.
25*3f982cf4SFabien Sanglard   virtual void OnFatalError(Error error) = 0;
26*3f982cf4SFabien Sanglard 
27*3f982cf4SFabien Sanglard   // This method is called when an error is detected by the underlying
28*3f982cf4SFabien Sanglard   // infrastructure which does not prevent further functionality of the runtime.
29*3f982cf4SFabien Sanglard   // For example, a conversion failure between DnsSdInstanceRecord and the
30*3f982cf4SFabien Sanglard   // externally supplied class.
31*3f982cf4SFabien Sanglard   virtual void OnRecoverableError(Error error) = 0;
32*3f982cf4SFabien Sanglard };
33*3f982cf4SFabien Sanglard 
34*3f982cf4SFabien Sanglard }  // namespace discovery
35*3f982cf4SFabien Sanglard }  // namespace openscreen
36*3f982cf4SFabien Sanglard 
37*3f982cf4SFabien Sanglard #endif  // DISCOVERY_COMMON_REPORTING_CLIENT_H_
38