blob: 18e3129d01ea817e71c255b4486d02cb76670f99 [file] [log] [blame]
Ben Murdochbb1529c2013-08-08 10:24:53 +01001// 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 private:
39 api::log_private::Filter filter_;
40
41 DISALLOW_COPY_AND_ASSIGN(FilterHandler);
42};
43
44} // namespace extensions
45
46#endif // CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_FILTER_HANDLER_H_