Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 1 | // Copyright 2013 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_BROWSER_EXTENSIONS_API_LOG_PRIVATE_LOG_PARSER_H_ |
| 6 | #define CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_LOG_PARSER_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include "base/memory/linked_ptr.h" |
| 12 | #include "chrome/browser/extensions/api/log_private/filter_handler.h" |
| 13 | #include "chrome/common/extensions/api/log_private.h" |
| 14 | |
| 15 | namespace extensions { |
| 16 | |
| 17 | // This is a abstract class of parsers for different logs. |
| 18 | // All the specific parsers inherit from this class. |
| 19 | class LogParser { |
| 20 | public: |
| 21 | enum Error { |
| 22 | SUCCESS = 0, |
| 23 | PARSE_ERROR = -1, |
| 24 | SERIALIZE_ERROR = -2, |
| 25 | TOKENIZE_ERROR = -3 |
| 26 | }; |
| 27 | |
| 28 | virtual ~LogParser(); |
| 29 | // Parses log text into multiple LogEntry objects. |
| 30 | void Parse( |
| 31 | const std::string& input, |
| 32 | std::vector<linked_ptr<api::log_private::LogEntry> >* output, |
| 33 | FilterHandler* filter_handler) const; |
| 34 | |
| 35 | protected: |
| 36 | explicit LogParser(); |
| 37 | // Parses a single line of log text into one LogEntry object. |
| 38 | virtual Error ParseEntry( |
| 39 | const std::string& input, |
| 40 | std::vector<linked_ptr<api::log_private::LogEntry> >* output, |
| 41 | FilterHandler* filter_handler) const = 0; |
| 42 | |
| 43 | private: |
| 44 | DISALLOW_COPY_AND_ASSIGN(LogParser); |
| 45 | }; |
| 46 | |
| 47 | } // namespace extensions |
| 48 | |
| 49 | #endif // CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_LOG_PARSER_H_ |