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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_FILTER_HANDLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_FILTER_HANDLER_H_
11 #include "chrome/common/extensions/api/log_private.h"
13 namespace extensions {
14 // This class contains multiple filtering methods to filter log entries
15 // by multiple fields.
18 explicit FilterHandler(const api::log_private::Filter& filter);
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;
37 const api::log_private::Filter* GetFilter() const { return &filter_; }
40 api::log_private::Filter filter_;
42 DISALLOW_COPY_AND_ASSIGN(FilterHandler);
45 } // namespace extensions
47 #endif // CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_FILTER_HANDLER_H_