Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Side by Side Diff: third_party/WebKit/Source/core/workers/DedicatedWorkerTest.cpp

Issue 2811993007: Worker: Remove cross-thread PostTask functions from WorkerLoaderProxy (Closed)
Patch Set: address review comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 5 #include <memory>
6 #include "core/dom/TaskRunnerHelper.h" 6 #include "core/dom/TaskRunnerHelper.h"
7 #include "core/events/MessageEvent.h" 7 #include "core/events/MessageEvent.h"
8 #include "core/inspector/ConsoleMessageStorage.h" 8 #include "core/inspector/ConsoleMessageStorage.h"
9 #include "core/testing/DummyPageHolder.h" 9 #include "core/testing/DummyPageHolder.h"
10 #include "core/workers/DedicatedWorkerGlobalScope.h" 10 #include "core/workers/DedicatedWorkerGlobalScope.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 : public InProcessWorkerMessagingProxy { 85 : public InProcessWorkerMessagingProxy {
86 public: 86 public:
87 InProcessWorkerMessagingProxyForTest(ExecutionContext* execution_context) 87 InProcessWorkerMessagingProxyForTest(ExecutionContext* execution_context)
88 : InProcessWorkerMessagingProxy(execution_context, 88 : InProcessWorkerMessagingProxy(execution_context,
89 nullptr /* workerObject */, 89 nullptr /* workerObject */,
90 nullptr /* workerClients */) { 90 nullptr /* workerClients */) {
91 WorkerObjectProxy().default_interval_in_sec_ = kDefaultIntervalInSec; 91 WorkerObjectProxy().default_interval_in_sec_ = kDefaultIntervalInSec;
92 WorkerObjectProxy().next_interval_in_sec_ = kNextIntervalInSec; 92 WorkerObjectProxy().next_interval_in_sec_ = kNextIntervalInSec;
93 WorkerObjectProxy().max_interval_in_sec_ = kMaxIntervalInSec; 93 WorkerObjectProxy().max_interval_in_sec_ = kMaxIntervalInSec;
94 94
95 mock_worker_loader_proxy_provider_ = 95 worker_loader_proxy_provider_ =
96 WTF::MakeUnique<MockWorkerLoaderProxyProvider>(); 96 WTF::MakeUnique<WorkerLoaderProxyProvider>();
97 worker_thread_ = WTF::WrapUnique(new DedicatedWorkerThreadForTest( 97 worker_thread_ = WTF::WrapUnique(new DedicatedWorkerThreadForTest(
98 mock_worker_loader_proxy_provider_.get(), WorkerObjectProxy())); 98 worker_loader_proxy_provider_.get(), WorkerObjectProxy()));
99 mock_worker_thread_lifecycle_observer_ = 99 mock_worker_thread_lifecycle_observer_ =
100 new MockWorkerThreadLifecycleObserver( 100 new MockWorkerThreadLifecycleObserver(
101 worker_thread_->GetWorkerThreadLifecycleContext()); 101 worker_thread_->GetWorkerThreadLifecycleContext());
102 EXPECT_CALL(*mock_worker_thread_lifecycle_observer_, 102 EXPECT_CALL(*mock_worker_thread_lifecycle_observer_,
103 ContextDestroyed(::testing::_)) 103 ContextDestroyed(::testing::_))
104 .Times(1); 104 .Times(1);
105 } 105 }
106 106
107 ~InProcessWorkerMessagingProxyForTest() override { 107 ~InProcessWorkerMessagingProxyForTest() override {
108 EXPECT_FALSE(blocking_); 108 EXPECT_FALSE(blocking_);
109 worker_thread_->GetWorkerLoaderProxy()->DetachProvider( 109 worker_thread_->GetWorkerLoaderProxy()->DetachProvider(
110 mock_worker_loader_proxy_provider_.get()); 110 worker_loader_proxy_provider_.get());
111 } 111 }
112 112
113 void StartWithSourceCode(const String& source) { 113 void StartWithSourceCode(const String& source) {
114 KURL script_url(kParsedURLString, "http://fake.url/"); 114 KURL script_url(kParsedURLString, "http://fake.url/");
115 security_origin_ = SecurityOrigin::Create(script_url); 115 security_origin_ = SecurityOrigin::Create(script_url);
116 std::unique_ptr<Vector<CSPHeaderAndType>> headers = 116 std::unique_ptr<Vector<CSPHeaderAndType>> headers =
117 WTF::MakeUnique<Vector<CSPHeaderAndType>>(); 117 WTF::MakeUnique<Vector<CSPHeaderAndType>>();
118 CSPHeaderAndType header_and_type("contentSecurityPolicy", 118 CSPHeaderAndType header_and_type("contentSecurityPolicy",
119 kContentSecurityPolicyHeaderTypeReport); 119 kContentSecurityPolicyHeaderTypeReport);
120 headers->push_back(header_and_type); 120 headers->push_back(header_and_type);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 DedicatedWorkerThreadForTest* GetWorkerThread() { 186 DedicatedWorkerThreadForTest* GetWorkerThread() {
187 return static_cast<DedicatedWorkerThreadForTest*>(worker_thread_.get()); 187 return static_cast<DedicatedWorkerThreadForTest*>(worker_thread_.get());
188 } 188 }
189 189
190 unsigned UnconfirmedMessageCount() const { 190 unsigned UnconfirmedMessageCount() const {
191 return unconfirmed_message_count_; 191 return unconfirmed_message_count_;
192 } 192 }
193 193
194 private: 194 private:
195 std::unique_ptr<MockWorkerLoaderProxyProvider> 195 std::unique_ptr<WorkerLoaderProxyProvider> worker_loader_proxy_provider_;
196 mock_worker_loader_proxy_provider_;
197 Persistent<MockWorkerThreadLifecycleObserver> 196 Persistent<MockWorkerThreadLifecycleObserver>
198 mock_worker_thread_lifecycle_observer_; 197 mock_worker_thread_lifecycle_observer_;
199 RefPtr<SecurityOrigin> security_origin_; 198 RefPtr<SecurityOrigin> security_origin_;
200 199
201 WTF::Deque<Notification> events_; 200 WTF::Deque<Notification> events_;
202 bool blocking_ = false; 201 bool blocking_ = false;
203 }; 202 };
204 203
205 using Notification = InProcessWorkerMessagingProxyForTest::Notification; 204 using Notification = InProcessWorkerMessagingProxyForTest::Notification;
206 205
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, GetWorkerThread()) 406 TaskRunnerHelper::Get(TaskType::kUnspecedTimer, GetWorkerThread())
408 ->PostTask( 407 ->PostTask(
409 BLINK_FROM_HERE, 408 BLINK_FROM_HERE,
410 CrossThreadBind(&DedicatedWorkerThreadForTest::CountDeprecation, 409 CrossThreadBind(&DedicatedWorkerThreadForTest::CountDeprecation,
411 CrossThreadUnretained(GetWorkerThread()), kFeature2)); 410 CrossThreadUnretained(GetWorkerThread()), kFeature2));
412 testing::EnterRunLoop(); 411 testing::EnterRunLoop();
413 EXPECT_TRUE(UseCounter::IsCounted(GetDocument(), kFeature2)); 412 EXPECT_TRUE(UseCounter::IsCounted(GetDocument(), kFeature2));
414 } 413 }
415 414
416 } // namespace blink 415 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698