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