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 com.dom_distiller.client; | 5 package com.dom_distiller.client; |
6 | 6 |
7 import com.dom_distiller.proto.DomDistillerProtos; | 7 import com.dom_distiller.proto.DomDistillerProtos; |
8 import com.dom_distiller.proto.DomDistillerProtos.DebugInfo; | 8 import com.dom_distiller.proto.DomDistillerProtos.DebugInfo; |
9 import com.dom_distiller.proto.DomDistillerProtos.TimingInfo; | 9 import com.dom_distiller.proto.DomDistillerProtos.TimingInfo; |
10 import com.google.gwt.dom.client.Document; | 10 import com.google.gwt.dom.client.Document; |
| 11 import com.google.gwt.core.client.js.JsExport; |
| 12 import com.google.gwt.core.client.js.JsNamespace; |
11 | 13 |
12 import org.timepedia.exporter.client.Export; | 14 @JsExport("DomDistiller") |
13 import org.timepedia.exporter.client.Exportable; | 15 public class DomDistiller { |
14 | 16 @JsExport |
15 @Export() | |
16 public class DomDistiller implements Exportable { | |
17 public static DomDistillerProtos.DomDistillerResult apply() { | 17 public static DomDistillerProtos.DomDistillerResult apply() { |
18 return applyWithOptions(DomDistillerProtos.DomDistillerOptions.create())
; | 18 return applyWithOptions(DomDistillerProtos.DomDistillerOptions.create())
; |
19 } | 19 } |
20 | 20 |
| 21 @JsExport |
21 public static DomDistillerProtos.DomDistillerResult applyWithOptions( | 22 public static DomDistillerProtos.DomDistillerResult applyWithOptions( |
22 DomDistillerProtos.DomDistillerOptions options) { | 23 DomDistillerProtos.DomDistillerOptions options) { |
23 double startTime = DomUtil.getTime(); | 24 double startTime = DomUtil.getTime(); |
24 DomDistillerProtos.DomDistillerResult result = | 25 DomDistillerProtos.DomDistillerResult result = |
25 DomDistillerProtos.DomDistillerResult.create(); | 26 DomDistillerProtos.DomDistillerResult.create(); |
26 ContentExtractor contentExtractor = | 27 ContentExtractor contentExtractor = |
27 new ContentExtractor(Document.get().getDocumentElement()); | 28 new ContentExtractor(Document.get().getDocumentElement()); |
28 result.setTitle(contentExtractor.extractTitle()); | 29 result.setTitle(contentExtractor.extractTitle()); |
29 | 30 |
30 LogUtil.setDebugLevel( | 31 LogUtil.setDebugLevel( |
(...skipping 16 matching lines...) Expand all Loading... |
47 TimingInfo timingInfo = contentExtractor.getTimingInfo(); | 48 TimingInfo timingInfo = contentExtractor.getTimingInfo(); |
48 timingInfo.setTotalTime(DomUtil.getTime() - startTime); | 49 timingInfo.setTotalTime(DomUtil.getTime() - startTime); |
49 result.setTimingInfo(timingInfo); | 50 result.setTimingInfo(timingInfo); |
50 result.setStatisticsInfo(contentExtractor.getStatisticsInfo()); | 51 result.setStatisticsInfo(contentExtractor.getStatisticsInfo()); |
51 DebugInfo debugInfo = DebugInfo.create(); | 52 DebugInfo debugInfo = DebugInfo.create(); |
52 debugInfo.setLog(LogUtil.getAndClearLog()); | 53 debugInfo.setLog(LogUtil.getAndClearLog()); |
53 result.setDebugInfo(debugInfo); | 54 result.setDebugInfo(debugInfo); |
54 return result; | 55 return result; |
55 } | 56 } |
56 } | 57 } |
OLD | NEW |