<commit_before><!DOCTYPE html>
<!--
Copyright 2017 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<link rel="import" href="/tracing/base/raf.html">
<link rel="import" href="/tracing/base/timing.html">
<link rel="import" href="/tracing/value/histogram_set.html">

<script>
'use strict';
tr.exportTo('tr.v', function() {
  class HistogramImporter {
    /**
     * @param {!Element} loadingEl
     */
    constructor(loadingEl) {
      this.loadingEl_ = loadingEl;
      this.histograms_ = undefined;
      this.jsonEls_ = [];
      this.jsonDivIndex_ = 0;
      this.view_ = undefined;
      this.fmpMark_ = tr.b.Timing.mark('HistogramImporter', 'fmp');

      this.loadingEl_.textContent = 'Parsing HTML...';
      // The json divs appear after this script tag in results.html, so the
      // browser will parse them into DOM now.
    }

    /**
     * @param {string} message
     * @return {Promise} resolves when |message| is displayed.
     */
    async update_(message) {
      this.loadingEl_.textContent = message;
      await tr.b.animationFrame();
    }

    /**
     * Each jsonEl should contain a Histogram JSON in its innerHTML.
     * The |view| should have display: none so that it doesn't obnoxiously
     * display "zero Histograms" while they are being imported.
     *
     * @param {!Array.<!Element>} jsonEls
     * @param {!Element} view A histogram-set-view.
     * @return {Promise} resolves when |view| is displayed.<commit_msg>tracing: Avoid rAF callbacks when hidden.<commit_after><!DOCTYPE html>
<!--
Copyright 2017 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<link rel="import" href="/tracing/base/raf.html">
<link rel="import" href="/tracing/base/timing.html">
<link rel="import" href="/tracing/value/histogram_set.html">

<script>
'use strict';
tr.exportTo('tr.v', function() {
  class HistogramImporter {
    /**
     * @param {!Element} loadingEl
     */
    constructor(loadingEl) {
      this.loadingEl_ = loadingEl;
      this.histograms_ = undefined;
      this.jsonEls_ = [];
      this.jsonDivIndex_ = 0;
      this.view_ = undefined;
      this.fmpMark_ = tr.b.Timing.mark('HistogramImporter', 'fmp');

      this.loadingEl_.textContent = 'Parsing HTML...';
      // The json divs appear after this script tag in results.html, so the
      // browser will parse them into DOM now.
    }

    /**
     * @param {string} message
     * @return {Promise} resolves when |message| is displayed.
     */
    async update_(message) {
      this.loadingEl_.textContent = message;
      // Use rAF callbacks only if the document is visible. If the document is
      // hidden, then the user-agent can stop triggering the rAF callbacks. So
      // avoid rAF callbacks when hidden.
      if (window.document.visibilityState === 'visible') {
        await tr.b.animationFrame();
      }
    }

    /**
     * Each jsonEl should contain a Histogram JSON in its innerHTML.
     * The |view| should have display: none so that it doesn't obnoxiously
     * display "zero Histograms" while they are being imported.
     *
     * @param {!Array.<!Element>} jsonEls
     * @param {!Element} view A histogram-set-view.
     * @return {Promise} resolves when |view| is displayed.
{'fraction_non_alphanumeric': 0.12238893792291851, 'fraction_numerical': 0.0029420417769932335, 'mean_word_length': 2.859250851305335, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4111713', 'n_tokens_mistral': 1045, 'n_tokens_neox': 1012, 'n_words': 322}