Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: blimp/common/logging.h

Issue 1933053003: Used oneof in blimp_message.proto (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « blimp/common/create_blimp_message_unittest.cc ('k') | blimp/common/logging.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 26 matching lines...) Expand all
37 // Registry of log extractors. 37 // Registry of log extractors.
38 class BLIMP_COMMON_EXPORT BlimpMessageLogger { 38 class BLIMP_COMMON_EXPORT BlimpMessageLogger {
39 public: 39 public:
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
48 // |type_name|: The human readable name of |type|. 48 // |feature_case|.
49 void AddHandler(const std::string& type_name, 49 // |feature_name|: The human readable name of |feature_case|.
50 BlimpMessage::Type type, 50 void AddHandler(const std::string& feature_name,
51 BlimpMessage::FeatureCase feature_case,
51 std::unique_ptr<LogExtractor> extractor); 52 std::unique_ptr<LogExtractor> extractor);
52 53
53 // Registry of log extractors. Map structure is: 54 // Registry of log extractors. Map structure is:
54 // {message type => (human readable message type, LogExtractor*)} 55 // {message type => (human readable message type, LogExtractor*)}
55 std::map<BlimpMessage::Type, 56 std::map<BlimpMessage::FeatureCase,
56 std::pair<std::string, std::unique_ptr<LogExtractor>>> 57 std::pair<std::string, std::unique_ptr<LogExtractor>>>
57 extractors_; 58 extractors_;
58 59
59 DISALLOW_COPY_AND_ASSIGN(BlimpMessageLogger); 60 DISALLOW_COPY_AND_ASSIGN(BlimpMessageLogger);
60 }; 61 };
61 62
62 // Serializes a BlimpMessage in a human-readable format for logging. 63 // Serializes a BlimpMessage in a human-readable format for logging.
63 // An example message would look like: 64 // An example message would look like:
64 // "<type=TAB_CONTROL subtype=SIZE size=640x480:1.000000 size=19>" 65 // "<type=TAB_CONTROL subtype=SIZE size=640x480:1.000000 size=19>"
65 BLIMP_COMMON_EXPORT std::ostream& operator<<(std::ostream& out, 66 BLIMP_COMMON_EXPORT std::ostream& operator<<(std::ostream& out,
66 const BlimpMessage& message); 67 const BlimpMessage& message);
67 68
68 } // namespace blimp 69 } // namespace blimp
69 70
70 #endif // BLIMP_COMMON_LOGGING_H_ 71 #endif // BLIMP_COMMON_LOGGING_H_
OLDNEW
« no previous file with comments | « blimp/common/create_blimp_message_unittest.cc ('k') | blimp/common/logging.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698