Ref<CompiledContentExtension> compileRuleList(const String& ruleList) { auto parsedRuleList = parseRuleList(ruleList); #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING double nfaBuildTimeStart = monotonicallyIncreasingTime(); #endif Vector<SerializedActionByte> actions; Vector<unsigned> actionLocations = serializeActions(parsedRuleList, actions); NFA nfa; URLFilterParser urlFilterParser(nfa); for (unsigned ruleIndex = 0; ruleIndex < parsedRuleList.size(); ++ruleIndex) { const ContentExtensionRule& contentExtensionRule = parsedRuleList[ruleIndex]; const Trigger& trigger = contentExtensionRule.trigger(); ASSERT(trigger.urlFilter.length()); String error = urlFilterParser.addPattern(trigger.urlFilter, trigger.urlFilterIsCaseSensitive, actionLocations[ruleIndex]); if (!error.isNull()) { dataLogF("Error while parsing %s: %s\n", trigger.urlFilter.utf8().data(), error.utf8().data()); continue; } } #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING double nfaBuildTimeEnd = monotonicallyIncreasingTime(); dataLogF(" Time spent building the NFA: %f\n", (nfaBuildTimeEnd - nfaBuildTimeStart)); #endif #if CONTENT_EXTENSIONS_STATE_MACHINE_DEBUGGING nfa.debugPrintDot(); #endif #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING double dfaBuildTimeStart = monotonicallyIncreasingTime(); #endif const DFA dfa = NFAToDFA::convert(nfa); #if CONTENT_EXTENSIONS_PERFORMANCE_REPORTING double dfaBuildTimeEnd = monotonicallyIncreasingTime(); dataLogF(" Time spent building the DFA: %f\n", (dfaBuildTimeEnd - dfaBuildTimeStart)); #endif // FIXME: never add a DFA that only matches the empty set. #if CONTENT_EXTENSIONS_STATE_MACHINE_DEBUGGING dfa.debugPrintDot(); #endif Vector<DFABytecode> bytecode; DFABytecodeCompiler compiler(dfa, bytecode); compiler.compile(); return CompiledContentExtension::create(WTF::move(bytecode), WTF::move(actions)); }