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

Side by Side Diff: content/browser/service_worker/service_worker_browsertest.cc

Issue 2491613004: Make base::Timer sequence-friendly. (Closed)
Patch Set: add back commented out DCHECK in Stop() Created 3 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 656
657 // Make the registration findable via storage functions. 657 // Make the registration findable via storage functions.
658 wrapper()->context()->storage()->NotifyInstallingRegistration( 658 wrapper()->context()->storage()->NotifyInstallingRegistration(
659 registration_.get()); 659 registration_.get());
660 660
661 AssociateRendererProcessToPattern(pattern); 661 AssociateRendererProcessToPattern(pattern);
662 } 662 }
663 663
664 void TimeoutWorkerOnIOThread() { 664 void TimeoutWorkerOnIOThread() {
665 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); 665 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
666 EXPECT_TRUE(version_->timeout_timer_.IsRunning());
666 version_->SimulatePingTimeoutForTesting(); 667 version_->SimulatePingTimeoutForTesting();
667 } 668 }
668 669
669 void AddControlleeOnIOThread() { 670 void AddControlleeOnIOThread() {
670 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); 671 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
671 std::unique_ptr<ServiceWorkerProviderHost> host = 672 std::unique_ptr<ServiceWorkerProviderHost> host =
672 CreateProviderHostForWindow(33 /* dummy render process id */, 673 CreateProviderHostForWindow(33 /* dummy render process id */,
673 1 /* dummy provider_id */, 674 1 /* dummy provider_id */,
674 true /* is_parent_frame_secure */, 675 true /* is_parent_frame_secure */,
675 wrapper()->context()->AsWeakPtr()); 676 wrapper()->context()->AsWeakPtr());
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 RunOnIOThread(base::Bind(&EmbeddedWorkerInstance::RemoveListener, 1168 RunOnIOThread(base::Bind(&EmbeddedWorkerInstance::RemoveListener,
1168 base::Unretained(version_->embedded_worker()), 1169 base::Unretained(version_->embedded_worker()),
1169 &wait_for_load)); 1170 &wait_for_load));
1170 1171
1171 // The script has loaded but start has not completed yet. 1172 // The script has loaded but start has not completed yet.
1172 ASSERT_EQ(SERVICE_WORKER_ERROR_FAILED, status); 1173 ASSERT_EQ(SERVICE_WORKER_ERROR_FAILED, status);
1173 EXPECT_EQ(EmbeddedWorkerStatus::STARTING, version_->running_status()); 1174 EXPECT_EQ(EmbeddedWorkerStatus::STARTING, version_->running_status());
1174 1175
1175 // Simulate execution timeout. Use a delay to prevent killing the worker 1176 // Simulate execution timeout. Use a delay to prevent killing the worker
1176 // before it's started execution. 1177 // before it's started execution.
1177 EXPECT_TRUE(version_->timeout_timer_.IsRunning());
1178 RunOnIOThreadWithDelay( 1178 RunOnIOThreadWithDelay(
1179 base::Bind(&self::TimeoutWorkerOnIOThread, base::Unretained(this)), 1179 base::Bind(&self::TimeoutWorkerOnIOThread, base::Unretained(this)),
1180 base::TimeDelta::FromMilliseconds(100)); 1180 base::TimeDelta::FromMilliseconds(100));
1181 start_run_loop.Run(); 1181 start_run_loop.Run();
1182 1182
1183 EXPECT_EQ(SERVICE_WORKER_ERROR_TIMEOUT, status); 1183 EXPECT_EQ(SERVICE_WORKER_ERROR_TIMEOUT, status);
1184 } 1184 }
1185 1185
1186 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, TimeoutWorkerInEvent) { 1186 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, TimeoutWorkerInEvent) {
1187 StartServerAndNavigateToSetup(); 1187 StartServerAndNavigateToSetup();
(...skipping 13 matching lines...) Expand all
1201 1201
1202 // Dispatch an event. 1202 // Dispatch an event.
1203 base::RunLoop install_run_loop; 1203 base::RunLoop install_run_loop;
1204 BrowserThread::PostTask( 1204 BrowserThread::PostTask(
1205 BrowserThread::IO, FROM_HERE, 1205 BrowserThread::IO, FROM_HERE,
1206 base::Bind(&self::InstallOnIOThread, base::Unretained(this), 1206 base::Bind(&self::InstallOnIOThread, base::Unretained(this),
1207 install_run_loop.QuitClosure(), &status)); 1207 install_run_loop.QuitClosure(), &status));
1208 1208
1209 // Simulate execution timeout. Use a delay to prevent killing the worker 1209 // Simulate execution timeout. Use a delay to prevent killing the worker
1210 // before it's started execution. 1210 // before it's started execution.
1211 EXPECT_TRUE(version_->timeout_timer_.IsRunning());
1212 RunOnIOThreadWithDelay( 1211 RunOnIOThreadWithDelay(
1213 base::Bind(&self::TimeoutWorkerOnIOThread, base::Unretained(this)), 1212 base::Bind(&self::TimeoutWorkerOnIOThread, base::Unretained(this)),
1214 base::TimeDelta::FromMilliseconds(100)); 1213 base::TimeDelta::FromMilliseconds(100));
1215 install_run_loop.Run(); 1214 install_run_loop.Run();
1216 1215
1217 // Terminating a worker, even one in an infinite loop, is treated as if 1216 // Terminating a worker, even one in an infinite loop, is treated as if
1218 // waitUntil was rejected in the renderer code. 1217 // waitUntil was rejected in the renderer code.
1219 EXPECT_EQ(SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED, status); 1218 EXPECT_EQ(SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED, status);
1220 } 1219 }
1221 1220
(...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after
3028 // effect in CanSuspendRenderer(). 3027 // effect in CanSuspendRenderer().
3029 shell()->web_contents()->WasHidden(); 3028 shell()->web_contents()->WasHidden();
3030 EXPECT_TRUE(rph->IsProcessBackgrounded()); 3029 EXPECT_TRUE(rph->IsProcessBackgrounded());
3031 3030
3032 // The process which has service worker thread shouldn't be suspended. 3031 // The process which has service worker thread shouldn't be suspended.
3033 EXPECT_FALSE(memory_coordinator->CanSuspendRenderer(render_process_id)); 3032 EXPECT_FALSE(memory_coordinator->CanSuspendRenderer(render_process_id));
3034 } 3033 }
3035 #endif 3034 #endif
3036 3035
3037 } // namespace content 3036 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698