| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BLIMP_COMMON_LOGGING_H_ | 5 #ifndef BLIMP_COMMON_LOGGING_H_ |
| 6 #define BLIMP_COMMON_LOGGING_H_ | 6 #define BLIMP_COMMON_LOGGING_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 BlimpMessageLogger(); | 40 BlimpMessageLogger(); |
| 41 ~BlimpMessageLogger(); | 41 ~BlimpMessageLogger(); |
| 42 | 42 |
| 43 // Formats the loggable representation of |message| and sends it to |out|. | 43 // Formats the loggable representation of |message| and sends it to |out|. |
| 44 void LogMessageToStream(const BlimpMessage& message, std::ostream* out) const; | 44 void LogMessageToStream(const BlimpMessage& message, std::ostream* out) const; |
| 45 | 45 |
| 46 private: | 46 private: |
| 47 // Adds |extractor| to the registry for parsing messages of type |type|. | 47 // Adds |extractor| to the registry for parsing messages of type |type|. |
| 48 // |type_name|: The human readable name of |type|. | 48 // |type_name|: The human readable name of |type|. |
| 49 void AddHandler(const std::string& type_name, | 49 void AddHandler(const std::string& type_name, |
| 50 BlimpMessage::Type type, | 50 BlimpMessage::FeatureCase type, |
| 51 std::unique_ptr<LogExtractor> extractor); | 51 std::unique_ptr<LogExtractor> extractor); |
| 52 | 52 |
| 53 // Registry of log extractors. Map structure is: | 53 // Registry of log extractors. Map structure is: |
| 54 // {message type => (human readable message type, LogExtractor*)} | 54 // {message type => (human readable message type, LogExtractor*)} |
| 55 std::map<BlimpMessage::Type, | 55 std::map<BlimpMessage::FeatureCase, |
| 56 std::pair<std::string, std::unique_ptr<LogExtractor>>> | 56 std::pair<std::string, std::unique_ptr<LogExtractor>>> |
| 57 extractors_; | 57 extractors_; |
| 58 | 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(BlimpMessageLogger); | 59 DISALLOW_COPY_AND_ASSIGN(BlimpMessageLogger); |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 // Serializes a BlimpMessage in a human-readable format for logging. | 62 // Serializes a BlimpMessage in a human-readable format for logging. |
| 63 // An example message would look like: | 63 // An example message would look like: |
| 64 // "<type=TAB_CONTROL subtype=SIZE size=640x480:1.000000 size=19>" | 64 // "<type=TAB_CONTROL subtype=SIZE size=640x480:1.000000 size=19>" |
| 65 BLIMP_COMMON_EXPORT std::ostream& operator<<(std::ostream& out, | 65 BLIMP_COMMON_EXPORT std::ostream& operator<<(std::ostream& out, |
| 66 const BlimpMessage& message); | 66 const BlimpMessage& message); |
| 67 | 67 |
| 68 } // namespace blimp | 68 } // namespace blimp |
| 69 | 69 |
| 70 #endif // BLIMP_COMMON_LOGGING_H_ | 70 #endif // BLIMP_COMMON_LOGGING_H_ |
| OLD | NEW |