| 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 #include "chrome/browser/extensions/api/log_private/filter_handler.h" | 5 #include "chrome/browser/extensions/api/log_private/filter_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "chrome/common/extensions/api/log_private.h" | 11 #include "chrome/common/extensions/api/log_private.h" |
| 12 | 12 |
| 13 namespace extensions { | 13 namespace extensions { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 template <typename T> | 17 template <typename T> |
| 18 bool IsValidField(const std::vector<T>& filter, const T& field) { | 18 bool IsValidField(const std::vector<T>& filter, const T& field) { |
| 19 return (!filter.size() || | 19 return (!filter.size() || |
| 20 std::find(filter.begin(), filter.end(), field) != filter.end()); | 20 std::find(filter.begin(), filter.end(), field) != filter.end()); |
| 21 } | 21 } |
| 22 | 22 |
| 23 } // namespace | 23 } // namespace |
| 24 | 24 |
| 25 FilterHandler::FilterHandler(const api::log_private::Filter& filter) { | 25 FilterHandler::FilterHandler(const api::log_private::Filter& filter) { |
| 26 scoped_ptr<base::DictionaryValue> filter_value = filter.ToValue(); | 26 std::unique_ptr<base::DictionaryValue> filter_value = filter.ToValue(); |
| 27 api::log_private::Filter::Populate(*filter_value, &filter_); | 27 api::log_private::Filter::Populate(*filter_value, &filter_); |
| 28 } | 28 } |
| 29 | 29 |
| 30 FilterHandler::~FilterHandler() {} | 30 FilterHandler::~FilterHandler() {} |
| 31 | 31 |
| 32 bool FilterHandler::IsValidLogEntry( | 32 bool FilterHandler::IsValidLogEntry( |
| 33 const api::log_private::LogEntry& entry) const { | 33 const api::log_private::LogEntry& entry) const { |
| 34 return (IsValidProcess(entry.process) && IsValidLevel(entry.level) && | 34 return (IsValidProcess(entry.process) && IsValidLevel(entry.level) && |
| 35 IsValidTime(entry.timestamp)); | 35 IsValidTime(entry.timestamp)); |
| 36 } | 36 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 50 | 50 |
| 51 bool FilterHandler::IsValidLevel(const std::string& level) const { | 51 bool FilterHandler::IsValidLevel(const std::string& level) const { |
| 52 return IsValidField(filter_.level, level); | 52 return IsValidField(filter_.level, level); |
| 53 } | 53 } |
| 54 | 54 |
| 55 bool FilterHandler::IsValidProcess(const std::string& process) const { | 55 bool FilterHandler::IsValidProcess(const std::string& process) const { |
| 56 return IsValidField(filter_.process, process); | 56 return IsValidField(filter_.process, process); |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // namespace extensions | 59 } // namespace extensions |
| OLD | NEW |