commit-queue@webkit.org | 9a7877a | 2012-10-18 01:56:10 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Intel Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 26 | #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_TIMING_PERFORMANCE_MARK_H_ |
| 27 | #define THIRD_PARTY_BLINK_RENDERER_CORE_TIMING_PERFORMANCE_MARK_H_ |
commit-queue@webkit.org | 9a7877a | 2012-10-18 01:56:10 | [diff] [blame] | 28 | |
Gabriel Charette | d87f10f | 2022-03-31 00:44:22 | [diff] [blame^] | 29 | #include "base/time/time.h" |
Yuta Kasai | e1f61030 | 2019-11-14 03:31:16 | [diff] [blame] | 30 | #include "third_party/blink/public/mojom/timing/performance_mark_or_measure.mojom-blink-forward.h" |
Liquan(Max) Gu | 5c5b8b19 | 2019-07-09 01:25:57 | [diff] [blame] | 31 | #include "third_party/blink/renderer/bindings/core/v8/serialization/serialized_script_value.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 32 | #include "third_party/blink/renderer/core/timing/performance_entry.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 33 | #include "third_party/blink/renderer/platform/bindings/trace_wrapper_v8_reference.h" |
Lei Zhang | b20a067 | 2022-02-28 18:53:50 | [diff] [blame] | 34 | #include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_map.h" |
Michael Lippautz | aaddb9d | 2021-11-22 13:22:07 | [diff] [blame] | 35 | #include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h" |
Liquan(Max) Gu | 5c5b8b19 | 2019-07-09 01:25:57 | [diff] [blame] | 36 | #include "third_party/blink/renderer/platform/heap/member.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 37 | #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" |
commit-queue@webkit.org | 9a7877a | 2012-10-18 01:56:10 | [diff] [blame] | 38 | |
abarth@chromium.org | 9969854 | 2014-07-18 22:10:43 | [diff] [blame] | 39 | namespace blink { |
commit-queue@webkit.org | 9a7877a | 2012-10-18 01:56:10 | [diff] [blame] | 40 | |
Liquan(Max) Gu | 086ccf0 | 2019-04-29 19:45:38 | [diff] [blame] | 41 | class ExceptionState; |
| 42 | class PerformanceMarkOptions; |
| 43 | |
panicker | 4a55e359 | 2016-05-20 05:57:51 | [diff] [blame] | 44 | class CORE_EXPORT PerformanceMark final : public PerformanceEntry { |
Blink Reformat | 1c8e1a7 | 2016-10-01 00:25:32 | [diff] [blame] | 45 | DEFINE_WRAPPERTYPEINFO(); |
commit-queue@webkit.org | 9a7877a | 2012-10-18 01:56:10 | [diff] [blame] | 46 | |
Blink Reformat | 1c8e1a7 | 2016-10-01 00:25:32 | [diff] [blame] | 47 | public: |
Tom McKee | d0f43c61 | 2020-02-24 23:34:43 | [diff] [blame] | 48 | // This method corresponds to the PerformanceMark constructor defined in the |
| 49 | // User Timing L3 spec |
| 50 | // (https://w3c.github.io/user-timing/#the-performancemark-constructor). It |
| 51 | // gets called as a subroutine of the `performance.mark` method as well as |
| 52 | // whenever script runs `new PerformanceMark(..)`. |
Liquan(Max) Gu | 086ccf0 | 2019-04-29 19:45:38 | [diff] [blame] | 53 | static PerformanceMark* Create(ScriptState*, |
| 54 | const AtomicString& mark_name, |
Liquan(Max) Gu | 086ccf0 | 2019-04-29 19:45:38 | [diff] [blame] | 55 | PerformanceMarkOptions*, |
| 56 | ExceptionState&); |
| 57 | |
Tom McKee | d0f43c61 | 2020-02-24 23:34:43 | [diff] [blame] | 58 | // This constructor is only public so that MakeGarbageCollected can call it. |
haoliuk | a997871 | 2022-02-17 17:43:11 | [diff] [blame] | 59 | PerformanceMark( |
| 60 | const AtomicString& name, |
| 61 | double start_time, |
| 62 | base::TimeTicks unsafe_time_for_traces, |
| 63 | scoped_refptr<SerializedScriptValue>, |
| 64 | ExceptionState& exception_state, |
| 65 | uint32_t navigation_count = 0); /* TODO(1273925): Remove the default value |
| 66 | when all callers have been updated. */ |
| 67 | |
Michael Lippautz | f759c84 | 2021-01-28 18:13:33 | [diff] [blame] | 68 | ~PerformanceMark() override = default; |
Keishi Hattori | 2fad33f | 2018-11-29 08:36:17 | [diff] [blame] | 69 | |
Nicolas Pena | c185601 | 2018-07-09 21:00:13 | [diff] [blame] | 70 | AtomicString entryType() const override; |
| 71 | PerformanceEntryType EntryTypeEnum() const override; |
Yuta Kasai | e1f61030 | 2019-11-14 03:31:16 | [diff] [blame] | 72 | mojom::blink::PerformanceMarkOrMeasurePtr ToMojoPerformanceMarkOrMeasure() |
| 73 | override; |
Nicolas Pena | c185601 | 2018-07-09 21:00:13 | [diff] [blame] | 74 | |
Liquan(Max) Gu | 5c5b8b19 | 2019-07-09 01:25:57 | [diff] [blame] | 75 | ScriptValue detail(ScriptState*); |
Liquan (Max) Gu | 669cfa8 | 2018-01-17 18:44:52 | [diff] [blame] | 76 | |
Omer Katz | 052831f | 2020-05-17 03:54:06 | [diff] [blame] | 77 | void Trace(Visitor*) const override; |
Liquan (Max) Gu | 669cfa8 | 2018-01-17 18:44:52 | [diff] [blame] | 78 | |
Yoav Weiss | 1ee40bf9 | 2021-03-23 11:47:57 | [diff] [blame] | 79 | base::TimeTicks UnsafeTimeForTraces() const { |
| 80 | return unsafe_time_for_traces_; |
| 81 | } |
| 82 | |
Blink Reformat | 1c8e1a7 | 2016-10-01 00:25:32 | [diff] [blame] | 83 | private: |
Liquan(Max) Gu | 5c5b8b19 | 2019-07-09 01:25:57 | [diff] [blame] | 84 | scoped_refptr<SerializedScriptValue> serialized_detail_; |
| 85 | // In order to prevent cross-world reference leak, we create a copy of the |
| 86 | // detail for each world. |
| 87 | HeapHashMap<WeakMember<ScriptState>, TraceWrapperV8Reference<v8::Value>> |
| 88 | deserialized_detail_map_; |
Yoav Weiss | 1ee40bf9 | 2021-03-23 11:47:57 | [diff] [blame] | 89 | base::TimeTicks unsafe_time_for_traces_; |
commit-queue@webkit.org | 9a7877a | 2012-10-18 01:56:10 | [diff] [blame] | 90 | }; |
| 91 | |
Blink Reformat | 1c8e1a7 | 2016-10-01 00:25:32 | [diff] [blame] | 92 | } // namespace blink |
commit-queue@webkit.org | 9a7877a | 2012-10-18 01:56:10 | [diff] [blame] | 93 | |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 94 | #endif // THIRD_PARTY_BLINK_RENDERER_CORE_TIMING_PERFORMANCE_MARK_H_ |