OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 package org.chromium.distiller; | 5 package org.chromium.distiller; |
6 | 6 |
7 import org.chromium.distiller.proto.DomDistillerProtos; | 7 import org.chromium.distiller.proto.DomDistillerProtos; |
8 import org.chromium.distiller.proto.DomDistillerProtos.DebugInfo; | 8 import org.chromium.distiller.proto.DomDistillerProtos.DebugInfo; |
9 import org.chromium.distiller.proto.DomDistillerProtos.TimingInfo; | 9 import org.chromium.distiller.proto.DomDistillerProtos.TimingInfo; |
| 10 import org.chromium.distiller.DomUtil; |
| 11 import org.chromium.distiller.StringUtil; |
10 | 12 |
11 import com.google.gwt.core.client.js.JsExport; | 13 import com.google.gwt.core.client.js.JsExport; |
12 import com.google.gwt.dom.client.Document; | 14 import com.google.gwt.dom.client.Document; |
13 import com.google.gwt.user.client.Window; | 15 import com.google.gwt.user.client.Window; |
14 | 16 |
15 @JsExport("DomDistiller") | 17 @JsExport("DomDistiller") |
16 public class DomDistiller { | 18 public class DomDistiller { |
17 @JsExport | 19 @JsExport |
18 public static DomDistillerProtos.DomDistillerResult apply() { | 20 public static DomDistillerProtos.DomDistillerResult apply() { |
19 return applyWithOptions(DomDistillerProtos.DomDistillerOptions.create())
; | 21 return applyWithOptions(DomDistillerProtos.DomDistillerOptions.create())
; |
20 } | 22 } |
21 | 23 |
22 @JsExport | 24 @JsExport |
23 public static DomDistillerProtos.DomDistillerResult applyWithOptions( | 25 public static DomDistillerProtos.DomDistillerResult applyWithOptions( |
24 DomDistillerProtos.DomDistillerOptions options) { | 26 DomDistillerProtos.DomDistillerOptions options) { |
25 double startTime = DomUtil.getTime(); | 27 double startTime = DomUtil.getTime(); |
| 28 StringUtil.setWordCounter( |
| 29 DomUtil.javascriptTextContent(Document.get().getDocumentElement(
))); |
26 DomDistillerProtos.DomDistillerResult result = | 30 DomDistillerProtos.DomDistillerResult result = |
27 DomDistillerProtos.DomDistillerResult.create(); | 31 DomDistillerProtos.DomDistillerResult.create(); |
28 ContentExtractor contentExtractor = | 32 ContentExtractor contentExtractor = |
29 new ContentExtractor(Document.get().getDocumentElement()); | 33 new ContentExtractor(Document.get().getDocumentElement()); |
30 result.setTitle(contentExtractor.extractTitle()); | 34 result.setTitle(contentExtractor.extractTitle()); |
31 | 35 |
32 LogUtil.setDebugLevel( | 36 LogUtil.setDebugLevel( |
33 options.hasDebugLevel() ? options.getDebugLevel() : LogUtil.DEBU
G_LEVEL_NONE); | 37 options.hasDebugLevel() ? options.getDebugLevel() : LogUtil.DEBU
G_LEVEL_NONE); |
34 LogUtil.logToConsole("DomDistiller debug level: " + LogUtil.getDebugLeve
l()); | 38 LogUtil.logToConsole("DomDistiller debug level: " + LogUtil.getDebugLeve
l()); |
35 | 39 |
(...skipping 15 matching lines...) Expand all Loading... |
51 result.setMarkupInfo(contentExtractor.getMarkupParser().getMarkupInfo())
; | 55 result.setMarkupInfo(contentExtractor.getMarkupParser().getMarkupInfo())
; |
52 timingInfo.setTotalTime(DomUtil.getTime() - startTime); | 56 timingInfo.setTotalTime(DomUtil.getTime() - startTime); |
53 result.setTimingInfo(timingInfo); | 57 result.setTimingInfo(timingInfo); |
54 result.setStatisticsInfo(contentExtractor.getStatisticsInfo()); | 58 result.setStatisticsInfo(contentExtractor.getStatisticsInfo()); |
55 DebugInfo debugInfo = DebugInfo.create(); | 59 DebugInfo debugInfo = DebugInfo.create(); |
56 debugInfo.setLog(LogUtil.getAndClearLog()); | 60 debugInfo.setLog(LogUtil.getAndClearLog()); |
57 result.setDebugInfo(debugInfo); | 61 result.setDebugInfo(debugInfo); |
58 return result; | 62 return result; |
59 } | 63 } |
60 } | 64 } |
OLD | NEW |