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