xref: /aosp_15_r20/external/cronet/base/notimplemented.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2024 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_NOTIMPLEMENTED_H_
6 #define BASE_NOTIMPLEMENTED_H_
7 
8 #include "base/check.h"
9 #include "base/dcheck_is_on.h"
10 
11 // The NOTIMPLEMENTED() macro annotates codepaths which have not been
12 // implemented yet. If output spam is a serious concern,
13 // NOTIMPLEMENTED_LOG_ONCE() can be used.
14 #if DCHECK_IS_ON()
15 #define NOTIMPLEMENTED() \
16   ::logging::CheckError::NotImplemented(__PRETTY_FUNCTION__)
17 
18 // The lambda returns false the first time it is run, and true every other time.
19 #define NOTIMPLEMENTED_LOG_ONCE()                                \
20   LOGGING_CHECK_FUNCTION_IMPL(NOTIMPLEMENTED(), []() {           \
21     bool old_value = true;                                       \
22     [[maybe_unused]] static const bool call_once = [](bool* b) { \
23       *b = false;                                                \
24       return true;                                               \
25     }(&old_value);                                               \
26     return old_value;                                            \
27   }())
28 
29 #else
30 #define NOTIMPLEMENTED() EAT_CHECK_STREAM_PARAMS()
31 #define NOTIMPLEMENTED_LOG_ONCE() EAT_CHECK_STREAM_PARAMS()
32 #endif
33 
34 #endif  // BASE_NOTIMPLEMENTED_H_
35