summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/components/blob_viewers/mixins.js
blob: 9e2b3097499eee3e0e9124c2a9cd1d41993b8c8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import {
  SNIPPET_MARK_VIEW_APP_START,
  SNIPPET_MARK_BLOBS_CONTENT,
  SNIPPET_MEASURE_BLOBS_CONTENT,
  SNIPPET_MEASURE_BLOBS_CONTENT_WITHIN_APP,
} from '~/performance_constants';

export default {
  props: {
    content: {
      type: String,
      required: true,
    },
    type: {
      type: String,
      required: true,
    },
  },
  mounted() {
    window.requestAnimationFrame(() => {
      if (!performance.getEntriesByName(SNIPPET_MARK_BLOBS_CONTENT).length) {
        performance.mark(SNIPPET_MARK_BLOBS_CONTENT);
        performance.measure(SNIPPET_MEASURE_BLOBS_CONTENT);
        performance.measure(SNIPPET_MEASURE_BLOBS_CONTENT_WITHIN_APP, SNIPPET_MARK_VIEW_APP_START);
      }
    });
  },
};