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

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

Issue 252893006: Remove the unused source_process_id and provider_host arguments to SW unregistration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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 "base/files/scoped_temp_dir.h" 5 #include "base/files/scoped_temp_dir.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "content/browser/browser_thread_impl.h" 8 #include "content/browser/browser_thread_impl.h"
9 #include "content/browser/service_worker/embedded_worker_registry.h" 9 #include "content/browser/service_worker/embedded_worker_registry.h"
10 #include "content/browser/service_worker/embedded_worker_test_helper.h" 10 #include "content/browser/service_worker/embedded_worker_test_helper.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 pattern, 240 pattern,
241 GURL("http://www.example.com/service_worker.js"), 241 GURL("http://www.example.com/service_worker.js"),
242 render_process_id_, 242 render_process_id_,
243 SaveRegistration(SERVICE_WORKER_OK, &called, &registration)); 243 SaveRegistration(SERVICE_WORKER_OK, &called, &registration));
244 244
245 ASSERT_FALSE(called); 245 ASSERT_FALSE(called);
246 base::RunLoop().RunUntilIdle(); 246 base::RunLoop().RunUntilIdle();
247 ASSERT_TRUE(called); 247 ASSERT_TRUE(called);
248 248
249 job_coordinator()->Unregister(pattern, 249 job_coordinator()->Unregister(pattern,
250 render_process_id_,
251 SaveUnregistration(SERVICE_WORKER_OK, &called)); 250 SaveUnregistration(SERVICE_WORKER_OK, &called));
252 251
253 ASSERT_FALSE(called); 252 ASSERT_FALSE(called);
254 base::RunLoop().RunUntilIdle(); 253 base::RunLoop().RunUntilIdle();
255 ASSERT_TRUE(called); 254 ASSERT_TRUE(called);
256 255
257 ASSERT_TRUE(registration->HasOneRef()); 256 ASSERT_TRUE(registration->HasOneRef());
258 257
259 storage()->FindRegistrationForPattern( 258 storage()->FindRegistrationForPattern(
260 pattern, 259 pattern,
261 SaveFoundRegistration(SERVICE_WORKER_ERROR_NOT_FOUND, 260 SaveFoundRegistration(SERVICE_WORKER_ERROR_NOT_FOUND,
262 &called, &registration)); 261 &called, &registration));
263 262
264 ASSERT_FALSE(called); 263 ASSERT_FALSE(called);
265 base::RunLoop().RunUntilIdle(); 264 base::RunLoop().RunUntilIdle();
266 ASSERT_TRUE(called); 265 ASSERT_TRUE(called);
267 266
268 ASSERT_EQ(scoped_refptr<ServiceWorkerRegistration>(NULL), registration); 267 ASSERT_EQ(scoped_refptr<ServiceWorkerRegistration>(NULL), registration);
269 } 268 }
270 269
271 TEST_F(ServiceWorkerJobTest, Unregister_NothingRegistered) { 270 TEST_F(ServiceWorkerJobTest, Unregister_NothingRegistered) {
272 GURL pattern("http://www.example.com/*"); 271 GURL pattern("http://www.example.com/*");
273 272
274 bool called; 273 bool called;
275 job_coordinator()->Unregister(pattern, 274 job_coordinator()->Unregister(pattern,
276 render_process_id_,
277 SaveUnregistration(SERVICE_WORKER_OK, &called)); 275 SaveUnregistration(SERVICE_WORKER_OK, &called));
278 276
279 ASSERT_FALSE(called); 277 ASSERT_FALSE(called);
280 base::RunLoop().RunUntilIdle(); 278 base::RunLoop().RunUntilIdle();
281 ASSERT_TRUE(called); 279 ASSERT_TRUE(called);
282 } 280 }
283 281
284 // Make sure that when a new registration replaces an existing 282 // Make sure that when a new registration replaces an existing
285 // registration, that the old one is cleaned up. 283 // registration, that the old one is cleaned up.
286 TEST_F(ServiceWorkerJobTest, RegisterNewScript) { 284 TEST_F(ServiceWorkerJobTest, RegisterNewScript) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 scoped_refptr<ServiceWorkerRegistration> registration; 440 scoped_refptr<ServiceWorkerRegistration> registration;
443 job_coordinator()->Register( 441 job_coordinator()->Register(
444 pattern, 442 pattern,
445 script_url, 443 script_url,
446 render_process_id_, 444 render_process_id_,
447 SaveRegistration(SERVICE_WORKER_OK, &registration_called, &registration)); 445 SaveRegistration(SERVICE_WORKER_OK, &registration_called, &registration));
448 446
449 bool unregistration_called = false; 447 bool unregistration_called = false;
450 job_coordinator()->Unregister( 448 job_coordinator()->Unregister(
451 pattern, 449 pattern,
452 render_process_id_,
453 SaveUnregistration(SERVICE_WORKER_OK, &unregistration_called)); 450 SaveUnregistration(SERVICE_WORKER_OK, &unregistration_called));
454 451
455 ASSERT_FALSE(registration_called); 452 ASSERT_FALSE(registration_called);
456 ASSERT_FALSE(unregistration_called); 453 ASSERT_FALSE(unregistration_called);
457 base::RunLoop().RunUntilIdle(); 454 base::RunLoop().RunUntilIdle();
458 ASSERT_TRUE(registration_called); 455 ASSERT_TRUE(registration_called);
459 ASSERT_TRUE(unregistration_called); 456 ASSERT_TRUE(unregistration_called);
460 457
461 bool find_called = false; 458 bool find_called = false;
462 storage()->FindRegistrationForPattern( 459 storage()->FindRegistrationForPattern(
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 } 555 }
559 556
560 // Call simulataneous unregister calls. 557 // Call simulataneous unregister calls.
561 TEST_F(ServiceWorkerJobTest, ParallelUnreg) { 558 TEST_F(ServiceWorkerJobTest, ParallelUnreg) {
562 GURL pattern("http://www.example.com/*"); 559 GURL pattern("http://www.example.com/*");
563 560
564 GURL script_url("http://www.example.com/service_worker.js"); 561 GURL script_url("http://www.example.com/service_worker.js");
565 bool unregistration1_called = false; 562 bool unregistration1_called = false;
566 job_coordinator()->Unregister( 563 job_coordinator()->Unregister(
567 pattern, 564 pattern,
568 render_process_id_,
569 SaveUnregistration(SERVICE_WORKER_OK, &unregistration1_called)); 565 SaveUnregistration(SERVICE_WORKER_OK, &unregistration1_called));
570 566
571 bool unregistration2_called = false; 567 bool unregistration2_called = false;
572 job_coordinator()->Unregister( 568 job_coordinator()->Unregister(
573 pattern, 569 pattern, SaveUnregistration(SERVICE_WORKER_OK, &unregistration2_called));
574 render_process_id_,
575 SaveUnregistration(SERVICE_WORKER_OK, &unregistration2_called));
576 570
577 ASSERT_FALSE(unregistration1_called); 571 ASSERT_FALSE(unregistration1_called);
578 ASSERT_FALSE(unregistration2_called); 572 ASSERT_FALSE(unregistration2_called);
579 base::RunLoop().RunUntilIdle(); 573 base::RunLoop().RunUntilIdle();
580 ASSERT_TRUE(unregistration1_called); 574 ASSERT_TRUE(unregistration1_called);
581 ASSERT_TRUE(unregistration2_called); 575 ASSERT_TRUE(unregistration2_called);
582 576
583 // There isn't really a way to test that they are being coalesced, 577 // There isn't really a way to test that they are being coalesced,
584 // but we can make sure they can exist simultaneously without 578 // but we can make sure they can exist simultaneously without
585 // crashing. 579 // crashing.
586 scoped_refptr<ServiceWorkerRegistration> registration; 580 scoped_refptr<ServiceWorkerRegistration> registration;
587 bool find_called = false; 581 bool find_called = false;
588 storage()->FindRegistrationForPattern( 582 storage()->FindRegistrationForPattern(
589 pattern, 583 pattern,
590 SaveFoundRegistration( 584 SaveFoundRegistration(
591 SERVICE_WORKER_ERROR_NOT_FOUND, &find_called, &registration)); 585 SERVICE_WORKER_ERROR_NOT_FOUND, &find_called, &registration));
592 586
593 base::RunLoop().RunUntilIdle(); 587 base::RunLoop().RunUntilIdle();
594 ASSERT_EQ(scoped_refptr<ServiceWorkerRegistration>(), registration); 588 ASSERT_EQ(scoped_refptr<ServiceWorkerRegistration>(), registration);
595 } 589 }
596 590
597 } // namespace content 591 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698