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/inspector/ConsoleMessageStorage.h" | 5 #include "core/inspector/ConsoleMessageStorage.h" |
6 #include "core/testing/DummyPageHolder.h" | 6 #include "core/testing/DummyPageHolder.h" |
7 #include "core/workers/ThreadedWorkletGlobalScope.h" | 7 #include "core/workers/ThreadedWorkletGlobalScope.h" |
8 #include "core/workers/ThreadedWorkletMessagingProxy.h" | 8 #include "core/workers/ThreadedWorkletMessagingProxy.h" |
9 #include "core/workers/ThreadedWorkletObjectProxy.h" | 9 #include "core/workers/ThreadedWorkletObjectProxy.h" |
10 #include "core/workers/WorkerInspectorProxy.h" | 10 #include "core/workers/WorkerInspectorProxy.h" |
| 11 #include "core/workers/WorkerTaskRunners.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" |
15 #include "platform/CrossThreadFunctional.h" | 16 #include "platform/CrossThreadFunctional.h" |
16 #include "platform/testing/UnitTestHelpers.h" | 17 #include "platform/testing/UnitTestHelpers.h" |
17 #include "platform/weborigin/SecurityOrigin.h" | 18 #include "platform/weborigin/SecurityOrigin.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 | 20 |
20 namespace blink { | 21 namespace blink { |
(...skipping 145 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 GetWorkerThread() |
177 BLINK_FROM_HERE, | 178 ->GetWorkerTaskRunners() |
178 CrossThreadBind(&ThreadedWorkletThreadForTest::CountFeature, | 179 ->Get(TaskType::kUnspecedTimer) |
179 CrossThreadUnretained(GetWorkerThread()), kFeature1)); | 180 ->PostTask( |
| 181 BLINK_FROM_HERE, |
| 182 CrossThreadBind(&ThreadedWorkletThreadForTest::CountFeature, |
| 183 CrossThreadUnretained(GetWorkerThread()), kFeature1)); |
180 testing::EnterRunLoop(); | 184 testing::EnterRunLoop(); |
181 EXPECT_TRUE(UseCounter::IsCounted(GetDocument(), kFeature1)); | 185 EXPECT_TRUE(UseCounter::IsCounted(GetDocument(), kFeature1)); |
182 | 186 |
183 // This feature is randomly selected from Deprecation::deprecationMessage(). | 187 // This feature is randomly selected from Deprecation::deprecationMessage(). |
184 const UseCounter::Feature kFeature2 = | 188 const UseCounter::Feature kFeature2 = |
185 UseCounter::Feature::kPrefixedStorageInfo; | 189 UseCounter::Feature::kPrefixedStorageInfo; |
186 | 190 |
187 // Deprecated API use on the ThreadedWorkletGlobalScope should be recorded in | 191 // Deprecated API use on the ThreadedWorkletGlobalScope should be recorded in |
188 // UseCounter on the Document. | 192 // UseCounter on the Document. |
189 EXPECT_FALSE(UseCounter::IsCounted(GetDocument(), kFeature2)); | 193 EXPECT_FALSE(UseCounter::IsCounted(GetDocument(), kFeature2)); |
190 GetWorkerThread()->PostTask( | 194 GetWorkerThread() |
191 BLINK_FROM_HERE, | 195 ->GetWorkerTaskRunners() |
192 CrossThreadBind(&ThreadedWorkletThreadForTest::CountDeprecation, | 196 ->Get(TaskType::kUnspecedTimer) |
193 CrossThreadUnretained(GetWorkerThread()), kFeature2)); | 197 ->PostTask( |
| 198 BLINK_FROM_HERE, |
| 199 CrossThreadBind(&ThreadedWorkletThreadForTest::CountDeprecation, |
| 200 CrossThreadUnretained(GetWorkerThread()), kFeature2)); |
194 testing::EnterRunLoop(); | 201 testing::EnterRunLoop(); |
195 EXPECT_TRUE(UseCounter::IsCounted(GetDocument(), kFeature2)); | 202 EXPECT_TRUE(UseCounter::IsCounted(GetDocument(), kFeature2)); |
196 } | 203 } |
197 | 204 |
198 } // namespace blink | 205 } // namespace blink |
OLD | NEW |