1 // Copyright 2019 The Chromium 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.
4 
5 #ifndef CHROME_CHROME_CLEANER_ENGINES_BROKER_INTERFACE_METADATA_OBSERVER_H_
6 #define CHROME_CHROME_CLEANER_ENGINES_BROKER_INTERFACE_METADATA_OBSERVER_H_
7 
8 #include <map>
9 #include <string>
10 
11 namespace chrome_cleaner {
12 
13 struct LogInformation {
14   std::string function_name;
15   std::string file_name;
16 };
17 
18 class InterfaceMetadataObserver {
19  public:
20   InterfaceMetadataObserver() = default;
21   virtual ~InterfaceMetadataObserver() = default;
22 
23   // Logs a call to |function_name| from the given |class_name| and also logs
24   // the passed parameters recorded on |params|.
25   virtual void ObserveCall(
26       const LogInformation& log_information,
27       const std::map<std::string, std::string>& params) = 0;
28 
29   // Logs a call to |function_name| without parameters.
30   virtual void ObserveCall(const LogInformation& log_information) = 0;
31 };
32 
33 // Define a macro to make the use of ObserveCall easier.
34 #define CURRENT_FILE_AND_METHOD \
35   LogInformation { __func__, __FILE__ }
36 
37 }  // namespace chrome_cleaner
38 
39 #endif  // CHROME_CHROME_CLEANER_ENGINES_BROKER_INTERFACE_METADATA_OBSERVER_H_
40