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_FILTER_HANDLER_H_ 6#define CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_FILTER_HANDLER_H_ 7 8#include <string> 9#include <vector> 10 11#include "chrome/common/extensions/api/log_private.h" 12 13namespace extensions { 14// This class contains multiple filtering methods to filter log entries 15// by multiple fields. 16class FilterHandler { 17 public: 18 explicit FilterHandler(const api::log_private::Filter& filter); 19 ~FilterHandler(); 20 21 // This function decides if a log entry should be returned to user. 22 // Returns true if the log entry meets the filtering conditions. 23 bool IsValidLogEntry(const api::log_private::LogEntry& entry) const; 24 // Filters log by timestamp. 25 // Returns true if the timestamp is within the time range of the filter. 26 bool IsValidTime(double time) const; 27 // Filters log by source (syslog, network_event_log, etc). 28 // Returns true if the log is from specified source in the filter. 29 bool IsValidSource(const std::string& source) const; 30 // Filters log by level (DEBUG, ERROR, WARNING). 31 // Returns true if the log level is specified in the filter. 32 bool IsValidLevel(const std::string& level) const; 33 // Filters log by its process name. 34 // Returns true if the process name is specified in the filter. 35 bool IsValidProcess(const std::string& process) const; 36 37 const api::log_private::Filter* GetFilter() const { return &filter_; } 38 39 private: 40 api::log_private::Filter filter_; 41 42 DISALLOW_COPY_AND_ASSIGN(FilterHandler); 43}; 44 45} // namespace extensions 46 47#endif // CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_FILTER_HANDLER_H_ 48