| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "core/dom/TaskRunnerHelper.h" | |
| 6 #include "core/inspector/ConsoleMessageStorage.h" | 5 #include "core/inspector/ConsoleMessageStorage.h" |
| 7 #include "core/testing/DummyPageHolder.h" | 6 #include "core/testing/DummyPageHolder.h" |
| 8 #include "core/workers/ThreadedWorkletGlobalScope.h" | 7 #include "core/workers/ThreadedWorkletGlobalScope.h" |
| 9 #include "core/workers/ThreadedWorkletMessagingProxy.h" | 8 #include "core/workers/ThreadedWorkletMessagingProxy.h" |
| 10 #include "core/workers/ThreadedWorkletObjectProxy.h" | 9 #include "core/workers/ThreadedWorkletObjectProxy.h" |
| 11 #include "core/workers/WorkerInspectorProxy.h" | 10 #include "core/workers/WorkerInspectorProxy.h" |
| 12 #include "core/workers/WorkerThread.h" | 11 #include "core/workers/WorkerThread.h" |
| 13 #include "core/workers/WorkerThreadStartupData.h" | 12 #include "core/workers/WorkerThreadStartupData.h" |
| 14 #include "core/workers/WorkerThreadTestHelper.h" | 13 #include "core/workers/WorkerThreadTestHelper.h" |
| 15 #include "core/workers/WorkletThreadHolder.h" | 14 #include "core/workers/WorkletThreadHolder.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 166 |
| 168 TEST_F(ThreadedWorkletTest, UseCounter) { | 167 TEST_F(ThreadedWorkletTest, UseCounter) { |
| 169 MessagingProxy()->Start(); | 168 MessagingProxy()->Start(); |
| 170 | 169 |
| 171 // This feature is randomly selected. | 170 // This feature is randomly selected. |
| 172 const UseCounter::Feature kFeature1 = UseCounter::Feature::kRequestFileSystem; | 171 const UseCounter::Feature kFeature1 = UseCounter::Feature::kRequestFileSystem; |
| 173 | 172 |
| 174 // API use on the DedicatedWorkerGlobalScope should be recorded in UseCounter | 173 // API use on the DedicatedWorkerGlobalScope should be recorded in UseCounter |
| 175 // on the Document. | 174 // on the Document. |
| 176 EXPECT_FALSE(UseCounter::IsCounted(GetDocument(), kFeature1)); | 175 EXPECT_FALSE(UseCounter::IsCounted(GetDocument(), kFeature1)); |
| 177 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, GetWorkerThread()) | 176 GetWorkerThread()->PostTask( |
| 178 ->PostTask( | 177 BLINK_FROM_HERE, |
| 179 BLINK_FROM_HERE, | 178 CrossThreadBind(&ThreadedWorkletThreadForTest::CountFeature, |
| 180 CrossThreadBind(&ThreadedWorkletThreadForTest::CountFeature, | 179 CrossThreadUnretained(GetWorkerThread()), kFeature1)); |
| 181 CrossThreadUnretained(GetWorkerThread()), kFeature1)); | |
| 182 testing::EnterRunLoop(); | 180 testing::EnterRunLoop(); |
| 183 EXPECT_TRUE(UseCounter::IsCounted(GetDocument(), kFeature1)); | 181 EXPECT_TRUE(UseCounter::IsCounted(GetDocument(), kFeature1)); |
| 184 | 182 |
| 185 // This feature is randomly selected from Deprecation::deprecationMessage(). | 183 // This feature is randomly selected from Deprecation::deprecationMessage(). |
| 186 const UseCounter::Feature kFeature2 = | 184 const UseCounter::Feature kFeature2 = |
| 187 UseCounter::Feature::kPrefixedStorageInfo; | 185 UseCounter::Feature::kPrefixedStorageInfo; |
| 188 | 186 |
| 189 // Deprecated API use on the ThreadedWorkletGlobalScope should be recorded in | 187 // Deprecated API use on the ThreadedWorkletGlobalScope should be recorded in |
| 190 // UseCounter on the Document. | 188 // UseCounter on the Document. |
| 191 EXPECT_FALSE(UseCounter::IsCounted(GetDocument(), kFeature2)); | 189 EXPECT_FALSE(UseCounter::IsCounted(GetDocument(), kFeature2)); |
| 192 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, GetWorkerThread()) | 190 GetWorkerThread()->PostTask( |
| 193 ->PostTask( | 191 BLINK_FROM_HERE, |
| 194 BLINK_FROM_HERE, | 192 CrossThreadBind(&ThreadedWorkletThreadForTest::CountDeprecation, |
| 195 CrossThreadBind(&ThreadedWorkletThreadForTest::CountDeprecation, | 193 CrossThreadUnretained(GetWorkerThread()), kFeature2)); |
| 196 CrossThreadUnretained(GetWorkerThread()), kFeature2)); | |
| 197 testing::EnterRunLoop(); | 194 testing::EnterRunLoop(); |
| 198 EXPECT_TRUE(UseCounter::IsCounted(GetDocument(), kFeature2)); | 195 EXPECT_TRUE(UseCounter::IsCounted(GetDocument(), kFeature2)); |
| 199 } | 196 } |
| 200 | 197 |
| 201 } // namespace blink | 198 } // namespace blink |
| OLD | NEW |