1<!DOCTYPE html> 2<!-- 3Copyright 2015 The Chromium Authors. All rights reserved. 4Use of this source code is governed by a BSD-style license that can be 5found in the LICENSE file. 6--> 7 8<link rel="import" href="/tracing/core/scripting_object.html"> 9 10<script> 11'use strict'; 12 13tr.exportTo('tr.e.tquery', function() { 14 function Filter() { 15 tr.c.ScriptingObject.call(this); 16 } 17 18 Filter.normalizeFilterExpression = function(filterExpression) { 19 // Shortcut: naked strings and regexps can be used to match against slice 20 // titles. 21 if (filterExpression instanceof String || 22 typeof(filterExpression) == 'string' || 23 filterExpression instanceof RegExp) { 24 var filter = new tr.e.tquery.FilterHasTitle(filterExpression); 25 return filter; 26 } 27 return filterExpression; 28 }; 29 30 Filter.prototype = { 31 __proto__: tr.c.ScriptingObject.prototype, 32 33 evaluate: function(context) { 34 throw new Error('Not implemented'); 35 }, 36 37 matchValue_: function(value, expected) { 38 if (expected instanceof RegExp) 39 return expected.test(value); 40 else if (expected instanceof Function) 41 return expected(value); 42 return value === expected; 43 } 44 }; 45 46 return { 47 Filter: Filter 48 }; 49}); 50</script> 51