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

Side by Side Diff: webkit/appcache/appcache_update_job_unittest.cc

Issue 517054: Remove all uses of EmptyString16(), EmptyWString(), and EmptyGURL(), and thei... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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 (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "base/thread.h" 8 #include "base/thread.h"
9 #include "base/waitable_event.h" 9 #include "base/waitable_event.h"
10 #include "net/url_request/url_request_test_job.h" 10 #include "net/url_request/url_request_test_job.h"
11 #include "net/url_request/url_request_unittest.h" 11 #include "net/url_request/url_request_unittest.h"
(...skipping 22 matching lines...) Expand all
34 virtual void OnEventRaised(const std::vector<int>& host_ids, 34 virtual void OnEventRaised(const std::vector<int>& host_ids,
35 EventID event_id) { 35 EventID event_id) {
36 raised_events_.push_back(RaisedEvent(host_ids, event_id)); 36 raised_events_.push_back(RaisedEvent(host_ids, event_id));
37 37
38 // Trigger additional updates if requested. 38 // Trigger additional updates if requested.
39 if (event_id == start_update_trigger_ && update_) { 39 if (event_id == start_update_trigger_ && update_) {
40 for (std::vector<AppCacheHost*>::iterator it = update_hosts_.begin(); 40 for (std::vector<AppCacheHost*>::iterator it = update_hosts_.begin();
41 it != update_hosts_.end(); ++it) { 41 it != update_hosts_.end(); ++it) {
42 AppCacheHost* host = *it; 42 AppCacheHost* host = *it;
43 update_->StartUpdate(host, 43 update_->StartUpdate(host,
44 (host ? host->pending_master_entry_url() : GURL::EmptyGURL())); 44 (host ? host->pending_master_entry_url() : GURL()));
45 } 45 }
46 update_hosts_.clear(); // only trigger once 46 update_hosts_.clear(); // only trigger once
47 } 47 }
48 } 48 }
49 49
50 void AddExpectedEvent(const std::vector<int>& host_ids, EventID event_id) { 50 void AddExpectedEvent(const std::vector<int>& host_ids, EventID event_id) {
51 expected_events_.push_back(RaisedEvent(host_ids, event_id)); 51 expected_events_.push_back(RaisedEvent(host_ids, event_id));
52 } 52 }
53 53
54 void TriggerAdditionalUpdates(EventID trigger_event, 54 void TriggerAdditionalUpdates(EventID trigger_event,
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 MakeService(); 320 MakeService();
321 group_ = new AppCacheGroup(service_.get(), GURL("http://failme"), 321 group_ = new AppCacheGroup(service_.get(), GURL("http://failme"),
322 service_->storage()->NewGroupId()); 322 service_->storage()->NewGroupId());
323 323
324 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 324 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
325 group_->update_job_ = update; 325 group_->update_job_ = update;
326 326
327 MockFrontend mock_frontend; 327 MockFrontend mock_frontend;
328 AppCacheHost host(1, &mock_frontend, service_.get()); 328 AppCacheHost host(1, &mock_frontend, service_.get());
329 329
330 update->StartUpdate(&host, GURL::EmptyGURL()); 330 update->StartUpdate(&host, GURL());
331 331
332 // Verify state. 332 // Verify state.
333 EXPECT_EQ(AppCacheUpdateJob::CACHE_ATTEMPT, update->update_type_); 333 EXPECT_EQ(AppCacheUpdateJob::CACHE_ATTEMPT, update->update_type_);
334 EXPECT_EQ(AppCacheUpdateJob::FETCH_MANIFEST, update->internal_state_); 334 EXPECT_EQ(AppCacheUpdateJob::FETCH_MANIFEST, update->internal_state_);
335 EXPECT_EQ(AppCacheGroup::CHECKING, group_->update_status()); 335 EXPECT_EQ(AppCacheGroup::CHECKING, group_->update_status());
336 336
337 // Verify notifications. 337 // Verify notifications.
338 MockFrontend::RaisedEvents& events = mock_frontend.raised_events_; 338 MockFrontend::RaisedEvents& events = mock_frontend.raised_events_;
339 size_t expected = 1; 339 size_t expected = 1;
340 EXPECT_EQ(expected, events.size()); 340 EXPECT_EQ(expected, events.size());
(...skipping 29 matching lines...) Expand all
370 AppCacheHost host2(2, &mock_frontend2, service_.get()); 370 AppCacheHost host2(2, &mock_frontend2, service_.get());
371 host2.AssociateCache(cache2); 371 host2.AssociateCache(cache2);
372 372
373 AppCacheHost host3(3, &mock_frontend1, service_.get()); 373 AppCacheHost host3(3, &mock_frontend1, service_.get());
374 host3.AssociateCache(cache1); 374 host3.AssociateCache(cache1);
375 375
376 AppCacheHost host4(4, &mock_frontend3, service_.get()); 376 AppCacheHost host4(4, &mock_frontend3, service_.get());
377 377
378 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 378 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
379 group_->update_job_ = update; 379 group_->update_job_ = update;
380 update->StartUpdate(&host4, GURL::EmptyGURL()); 380 update->StartUpdate(&host4, GURL());
381 381
382 // Verify state after starting an update. 382 // Verify state after starting an update.
383 EXPECT_EQ(AppCacheUpdateJob::UPGRADE_ATTEMPT, update->update_type_); 383 EXPECT_EQ(AppCacheUpdateJob::UPGRADE_ATTEMPT, update->update_type_);
384 EXPECT_EQ(AppCacheUpdateJob::FETCH_MANIFEST, update->internal_state_); 384 EXPECT_EQ(AppCacheUpdateJob::FETCH_MANIFEST, update->internal_state_);
385 EXPECT_EQ(AppCacheGroup::CHECKING, group_->update_status()); 385 EXPECT_EQ(AppCacheGroup::CHECKING, group_->update_status());
386 386
387 // Verify notifications. 387 // Verify notifications.
388 MockFrontend::RaisedEvents& events = mock_frontend1.raised_events_; 388 MockFrontend::RaisedEvents& events = mock_frontend1.raised_events_;
389 size_t expected = 1; 389 size_t expected = 1;
390 EXPECT_EQ(expected, events.size()); 390 EXPECT_EQ(expected, events.size());
(...skipping 26 matching lines...) Expand all
417 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); 417 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type());
418 418
419 MakeService(); 419 MakeService();
420 group_ = new AppCacheGroup(service_.get(), GURL("http://failme"), 420 group_ = new AppCacheGroup(service_.get(), GURL("http://failme"),
421 service_->storage()->NewGroupId()); 421 service_->storage()->NewGroupId());
422 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 422 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
423 group_->update_job_ = update; 423 group_->update_job_ = update;
424 424
425 MockFrontend* frontend = MakeMockFrontend(); 425 MockFrontend* frontend = MakeMockFrontend();
426 AppCacheHost* host = MakeHost(1, frontend); 426 AppCacheHost* host = MakeHost(1, frontend);
427 update->StartUpdate(host, GURL::EmptyGURL()); 427 update->StartUpdate(host, GURL());
428 EXPECT_TRUE(update->manifest_url_request_ != NULL); 428 EXPECT_TRUE(update->manifest_url_request_ != NULL);
429 429
430 update->manifest_url_request_->SimulateError(-100); 430 update->manifest_url_request_->SimulateError(-100);
431 431
432 // Set up checks for when update job finishes. 432 // Set up checks for when update job finishes.
433 do_checks_after_update_finished_ = true; 433 do_checks_after_update_finished_ = true;
434 expect_group_obsolete_ = false; 434 expect_group_obsolete_ = false;
435 expect_group_has_cache_ = false; 435 expect_group_has_cache_ = false;
436 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), 436 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
437 CHECKING_EVENT); 437 CHECKING_EVENT);
(...skipping 11 matching lines...) Expand all
449 group_->update_job_ = update; 449 group_->update_job_ = update;
450 450
451 AppCache* cache = MakeCacheForGroup(1, 111); 451 AppCache* cache = MakeCacheForGroup(1, 111);
452 MockFrontend* frontend1 = MakeMockFrontend(); 452 MockFrontend* frontend1 = MakeMockFrontend();
453 MockFrontend* frontend2 = MakeMockFrontend(); 453 MockFrontend* frontend2 = MakeMockFrontend();
454 AppCacheHost* host1 = MakeHost(1, frontend1); 454 AppCacheHost* host1 = MakeHost(1, frontend1);
455 AppCacheHost* host2 = MakeHost(2, frontend2); 455 AppCacheHost* host2 = MakeHost(2, frontend2);
456 host1->AssociateCache(cache); 456 host1->AssociateCache(cache);
457 host2->AssociateCache(cache); 457 host2->AssociateCache(cache);
458 458
459 update->StartUpdate(NULL, GURL::EmptyGURL()); 459 update->StartUpdate(NULL, GURL());
460 EXPECT_TRUE(update->manifest_url_request_ != NULL); 460 EXPECT_TRUE(update->manifest_url_request_ != NULL);
461 461
462 update->manifest_url_request_->SimulateError(-100); 462 update->manifest_url_request_->SimulateError(-100);
463 463
464 // Set up checks for when update job finishes. 464 // Set up checks for when update job finishes.
465 do_checks_after_update_finished_ = true; 465 do_checks_after_update_finished_ = true;
466 expect_group_obsolete_ = false; 466 expect_group_obsolete_ = false;
467 expect_group_has_cache_ = true; 467 expect_group_has_cache_ = true;
468 expect_newest_cache_ = cache; // newest cache unaffected by update 468 expect_newest_cache_ = cache; // newest cache unaffected by update
469 MockFrontend::HostIds ids1(1, host1->host_id()); 469 MockFrontend::HostIds ids1(1, host1->host_id());
(...skipping 14 matching lines...) Expand all
484 registered_factory_ = true; 484 registered_factory_ = true;
485 485
486 MakeService(); 486 MakeService();
487 group_ = new AppCacheGroup(service_.get(), GURL("http://testme"), 487 group_ = new AppCacheGroup(service_.get(), GURL("http://testme"),
488 service_->storage()->NewGroupId()); 488 service_->storage()->NewGroupId());
489 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 489 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
490 group_->update_job_ = update; 490 group_->update_job_ = update;
491 491
492 MockFrontend* frontend = MakeMockFrontend(); 492 MockFrontend* frontend = MakeMockFrontend();
493 AppCacheHost* host = MakeHost(1, frontend); 493 AppCacheHost* host = MakeHost(1, frontend);
494 update->StartUpdate(host, GURL::EmptyGURL()); 494 update->StartUpdate(host, GURL());
495 EXPECT_TRUE(update->manifest_url_request_ != NULL); 495 EXPECT_TRUE(update->manifest_url_request_ != NULL);
496 496
497 // Set up checks for when update job finishes. 497 // Set up checks for when update job finishes.
498 do_checks_after_update_finished_ = true; 498 do_checks_after_update_finished_ = true;
499 expect_group_obsolete_ = false; 499 expect_group_obsolete_ = false;
500 expect_group_has_cache_ = false; // redirect is like a failed request 500 expect_group_has_cache_ = false; // redirect is like a failed request
501 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), 501 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
502 CHECKING_EVENT); 502 CHECKING_EVENT);
503 503
504 WaitForUpdateToFinish(); 504 WaitForUpdateToFinish();
505 } 505 }
506 506
507 void ManifestWrongMimeTypeTest() { 507 void ManifestWrongMimeTypeTest() {
508 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); 508 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type());
509 509
510 MakeService(); 510 MakeService();
511 group_ = new AppCacheGroup( 511 group_ = new AppCacheGroup(
512 service_.get(), http_server_->TestServerPage("defaultresponse"), 512 service_.get(), http_server_->TestServerPage("defaultresponse"),
513 service_->storage()->NewGroupId()); 513 service_->storage()->NewGroupId());
514 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 514 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
515 group_->update_job_ = update; 515 group_->update_job_ = update;
516 516
517 MockFrontend* frontend = MakeMockFrontend(); 517 MockFrontend* frontend = MakeMockFrontend();
518 AppCacheHost* host = MakeHost(1, frontend); 518 AppCacheHost* host = MakeHost(1, frontend);
519 update->StartUpdate(host, GURL::EmptyGURL()); 519 update->StartUpdate(host, GURL());
520 EXPECT_TRUE(update->manifest_url_request_ != NULL); 520 EXPECT_TRUE(update->manifest_url_request_ != NULL);
521 521
522 // Set up checks for when update job finishes. 522 // Set up checks for when update job finishes.
523 do_checks_after_update_finished_ = true; 523 do_checks_after_update_finished_ = true;
524 expect_group_obsolete_ = false; 524 expect_group_obsolete_ = false;
525 expect_group_has_cache_ = false; // bad mime type is like a failed request 525 expect_group_has_cache_ = false; // bad mime type is like a failed request
526 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), 526 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
527 CHECKING_EVENT); 527 CHECKING_EVENT);
528 528
529 WaitForUpdateToFinish(); 529 WaitForUpdateToFinish();
(...skipping 10 matching lines...) Expand all
540 group_->update_job_ = update; 540 group_->update_job_ = update;
541 541
542 AppCache* cache = MakeCacheForGroup(1, 111); 542 AppCache* cache = MakeCacheForGroup(1, 111);
543 MockFrontend* frontend1 = MakeMockFrontend(); 543 MockFrontend* frontend1 = MakeMockFrontend();
544 MockFrontend* frontend2 = MakeMockFrontend(); 544 MockFrontend* frontend2 = MakeMockFrontend();
545 AppCacheHost* host1 = MakeHost(1, frontend1); 545 AppCacheHost* host1 = MakeHost(1, frontend1);
546 AppCacheHost* host2 = MakeHost(2, frontend2); 546 AppCacheHost* host2 = MakeHost(2, frontend2);
547 host1->AssociateCache(cache); 547 host1->AssociateCache(cache);
548 host2->AssociateCache(cache); 548 host2->AssociateCache(cache);
549 549
550 update->StartUpdate(NULL, GURL::EmptyGURL()); 550 update->StartUpdate(NULL, GURL());
551 EXPECT_TRUE(update->manifest_url_request_ != NULL); 551 EXPECT_TRUE(update->manifest_url_request_ != NULL);
552 552
553 // Set up checks for when update job finishes. 553 // Set up checks for when update job finishes.
554 do_checks_after_update_finished_ = true; 554 do_checks_after_update_finished_ = true;
555 expect_group_obsolete_ = true; 555 expect_group_obsolete_ = true;
556 expect_group_has_cache_ = true; 556 expect_group_has_cache_ = true;
557 expect_newest_cache_ = cache; // newest cache unaffected by update 557 expect_newest_cache_ = cache; // newest cache unaffected by update
558 MockFrontend::HostIds ids1(1, host1->host_id()); 558 MockFrontend::HostIds ids1(1, host1->host_id());
559 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT); 559 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
560 frontend1->AddExpectedEvent(ids1, OBSOLETE_EVENT); 560 frontend1->AddExpectedEvent(ids1, OBSOLETE_EVENT);
561 MockFrontend::HostIds ids2(1, host2->host_id()); 561 MockFrontend::HostIds ids2(1, host2->host_id());
562 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); 562 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT);
563 frontend2->AddExpectedEvent(ids2, OBSOLETE_EVENT); 563 frontend2->AddExpectedEvent(ids2, OBSOLETE_EVENT);
564 564
565 WaitForUpdateToFinish(); 565 WaitForUpdateToFinish();
566 } 566 }
567 567
568 void ManifestGoneTest() { 568 void ManifestGoneTest() {
569 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); 569 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type());
570 570
571 MakeService(); 571 MakeService();
572 group_ = new AppCacheGroup( 572 group_ = new AppCacheGroup(
573 service_.get(), http_server_->TestServerPage("files/gone"), 573 service_.get(), http_server_->TestServerPage("files/gone"),
574 service_->storage()->NewGroupId()); 574 service_->storage()->NewGroupId());
575 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 575 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
576 group_->update_job_ = update; 576 group_->update_job_ = update;
577 577
578 MockFrontend* frontend = MakeMockFrontend(); 578 MockFrontend* frontend = MakeMockFrontend();
579 AppCacheHost* host = MakeHost(1, frontend); 579 AppCacheHost* host = MakeHost(1, frontend);
580 update->StartUpdate(host, GURL::EmptyGURL()); 580 update->StartUpdate(host, GURL());
581 EXPECT_TRUE(update->manifest_url_request_ != NULL); 581 EXPECT_TRUE(update->manifest_url_request_ != NULL);
582 582
583 // Set up checks for when update job finishes. 583 // Set up checks for when update job finishes.
584 do_checks_after_update_finished_ = true; 584 do_checks_after_update_finished_ = true;
585 expect_group_obsolete_ = true; 585 expect_group_obsolete_ = true;
586 expect_group_has_cache_ = false; 586 expect_group_has_cache_ = false;
587 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), 587 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
588 CHECKING_EVENT); 588 CHECKING_EVENT);
589 589
590 WaitForUpdateToFinish(); 590 WaitForUpdateToFinish();
591 } 591 }
592 592
593 void CacheAttemptNotModifiedTest() { 593 void CacheAttemptNotModifiedTest() {
594 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); 594 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type());
595 595
596 MakeService(); 596 MakeService();
597 group_ = new AppCacheGroup( 597 group_ = new AppCacheGroup(
598 service_.get(), http_server_->TestServerPage("files/notmodified"), 598 service_.get(), http_server_->TestServerPage("files/notmodified"),
599 service_->storage()->NewGroupId()); 599 service_->storage()->NewGroupId());
600 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 600 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
601 group_->update_job_ = update; 601 group_->update_job_ = update;
602 602
603 MockFrontend* frontend = MakeMockFrontend(); 603 MockFrontend* frontend = MakeMockFrontend();
604 AppCacheHost* host = MakeHost(1, frontend); 604 AppCacheHost* host = MakeHost(1, frontend);
605 update->StartUpdate(host, GURL::EmptyGURL()); 605 update->StartUpdate(host, GURL());
606 EXPECT_TRUE(update->manifest_url_request_ != NULL); 606 EXPECT_TRUE(update->manifest_url_request_ != NULL);
607 607
608 // Set up checks for when update job finishes. 608 // Set up checks for when update job finishes.
609 do_checks_after_update_finished_ = true; 609 do_checks_after_update_finished_ = true;
610 expect_group_obsolete_ = false; 610 expect_group_obsolete_ = false;
611 expect_group_has_cache_ = false; // treated like cache failure 611 expect_group_has_cache_ = false; // treated like cache failure
612 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), 612 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
613 CHECKING_EVENT); 613 CHECKING_EVENT);
614 614
615 WaitForUpdateToFinish(); 615 WaitForUpdateToFinish();
(...skipping 10 matching lines...) Expand all
626 group_->update_job_ = update; 626 group_->update_job_ = update;
627 627
628 AppCache* cache = MakeCacheForGroup(1, 111); 628 AppCache* cache = MakeCacheForGroup(1, 111);
629 MockFrontend* frontend1 = MakeMockFrontend(); 629 MockFrontend* frontend1 = MakeMockFrontend();
630 MockFrontend* frontend2 = MakeMockFrontend(); 630 MockFrontend* frontend2 = MakeMockFrontend();
631 AppCacheHost* host1 = MakeHost(1, frontend1); 631 AppCacheHost* host1 = MakeHost(1, frontend1);
632 AppCacheHost* host2 = MakeHost(2, frontend2); 632 AppCacheHost* host2 = MakeHost(2, frontend2);
633 host1->AssociateCache(cache); 633 host1->AssociateCache(cache);
634 host2->AssociateCache(cache); 634 host2->AssociateCache(cache);
635 635
636 update->StartUpdate(NULL, GURL::EmptyGURL()); 636 update->StartUpdate(NULL, GURL());
637 EXPECT_TRUE(update->manifest_url_request_ != NULL); 637 EXPECT_TRUE(update->manifest_url_request_ != NULL);
638 638
639 // Set up checks for when update job finishes. 639 // Set up checks for when update job finishes.
640 do_checks_after_update_finished_ = true; 640 do_checks_after_update_finished_ = true;
641 expect_group_obsolete_ = false; 641 expect_group_obsolete_ = false;
642 expect_group_has_cache_ = true; 642 expect_group_has_cache_ = true;
643 expect_newest_cache_ = cache; // newest cache unaffected by update 643 expect_newest_cache_ = cache; // newest cache unaffected by update
644 MockFrontend::HostIds ids1(1, host1->host_id()); 644 MockFrontend::HostIds ids1(1, host1->host_id());
645 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT); 645 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
646 frontend1->AddExpectedEvent(ids1, NO_UPDATE_EVENT); 646 frontend1->AddExpectedEvent(ids1, NO_UPDATE_EVENT);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 703
704 // Start update after data write completes asynchronously. 704 // Start update after data write completes asynchronously.
705 } 705 }
706 706
707 void StartUpdateAfterSeedingStorageData(int result) { 707 void StartUpdateAfterSeedingStorageData(int result) {
708 ASSERT_GT(result, 0); 708 ASSERT_GT(result, 0);
709 write_callback_.reset(); 709 write_callback_.reset();
710 response_writer_.reset(); 710 response_writer_.reset();
711 711
712 AppCacheUpdateJob* update = group_->update_job_; 712 AppCacheUpdateJob* update = group_->update_job_;
713 update->StartUpdate(NULL, GURL::EmptyGURL()); 713 update->StartUpdate(NULL, GURL());
714 EXPECT_TRUE(update->manifest_url_request_ != NULL); 714 EXPECT_TRUE(update->manifest_url_request_ != NULL);
715 715
716 WaitForUpdateToFinish(); 716 WaitForUpdateToFinish();
717 } 717 }
718 718
719 void BasicCacheAttemptSuccessTest() { 719 void BasicCacheAttemptSuccessTest() {
720 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); 720 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type());
721 721
722 MakeService(); 722 MakeService();
723 group_ = new AppCacheGroup( 723 group_ = new AppCacheGroup(
724 service_.get(), http_server_->TestServerPage("files/manifest1"), 724 service_.get(), http_server_->TestServerPage("files/manifest1"),
725 service_->storage()->NewGroupId()); 725 service_->storage()->NewGroupId());
726 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 726 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
727 group_->update_job_ = update; 727 group_->update_job_ = update;
728 728
729 MockFrontend* frontend = MakeMockFrontend(); 729 MockFrontend* frontend = MakeMockFrontend();
730 AppCacheHost* host = MakeHost(1, frontend); 730 AppCacheHost* host = MakeHost(1, frontend);
731 update->StartUpdate(host, GURL::EmptyGURL()); 731 update->StartUpdate(host, GURL());
732 EXPECT_TRUE(update->manifest_url_request_ != NULL); 732 EXPECT_TRUE(update->manifest_url_request_ != NULL);
733 733
734 // Set up checks for when update job finishes. 734 // Set up checks for when update job finishes.
735 do_checks_after_update_finished_ = true; 735 do_checks_after_update_finished_ = true;
736 expect_group_obsolete_ = false; 736 expect_group_obsolete_ = false;
737 expect_group_has_cache_ = true; 737 expect_group_has_cache_ = true;
738 tested_manifest_ = MANIFEST1; 738 tested_manifest_ = MANIFEST1;
739 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), 739 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
740 CHECKING_EVENT); 740 CHECKING_EVENT);
741 741
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 AppCacheHost* host1 = MakeHost(1, frontend1); 991 AppCacheHost* host1 = MakeHost(1, frontend1);
992 AppCacheHost* host2 = MakeHost(2, frontend2); 992 AppCacheHost* host2 = MakeHost(2, frontend2);
993 host1->AssociateCache(cache); 993 host1->AssociateCache(cache);
994 host2->AssociateCache(cache); 994 host2->AssociateCache(cache);
995 995
996 // Give the newest cache a master entry that is also one of the explicit 996 // Give the newest cache a master entry that is also one of the explicit
997 // entries in the manifest. 997 // entries in the manifest.
998 cache->AddEntry(http_server_->TestServerPage("files/explicit1"), 998 cache->AddEntry(http_server_->TestServerPage("files/explicit1"),
999 AppCacheEntry(AppCacheEntry::MASTER, 111)); 999 AppCacheEntry(AppCacheEntry::MASTER, 111));
1000 1000
1001 update->StartUpdate(NULL, GURL::EmptyGURL()); 1001 update->StartUpdate(NULL, GURL());
1002 EXPECT_TRUE(update->manifest_url_request_ != NULL); 1002 EXPECT_TRUE(update->manifest_url_request_ != NULL);
1003 1003
1004 // Set up checks for when update job finishes. 1004 // Set up checks for when update job finishes.
1005 do_checks_after_update_finished_ = true; 1005 do_checks_after_update_finished_ = true;
1006 expect_group_obsolete_ = false; 1006 expect_group_obsolete_ = false;
1007 expect_group_has_cache_ = true; 1007 expect_group_has_cache_ = true;
1008 expect_old_cache_ = cache; 1008 expect_old_cache_ = cache;
1009 tested_manifest_ = MANIFEST_MERGED_TYPES; 1009 tested_manifest_ = MANIFEST_MERGED_TYPES;
1010 MockFrontend::HostIds ids1(1, host1->host_id()); 1010 MockFrontend::HostIds ids1(1, host1->host_id());
1011 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT); 1011 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
(...skipping 20 matching lines...) Expand all
1032 1032
1033 MakeService(); 1033 MakeService();
1034 group_ = new AppCacheGroup(service_.get(), 1034 group_ = new AppCacheGroup(service_.get(),
1035 http_server_->TestServerPage("files/manifest-with-404"), 1035 http_server_->TestServerPage("files/manifest-with-404"),
1036 service_->storage()->NewGroupId()); 1036 service_->storage()->NewGroupId());
1037 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 1037 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
1038 group_->update_job_ = update; 1038 group_->update_job_ = update;
1039 1039
1040 MockFrontend* frontend = MakeMockFrontend(); 1040 MockFrontend* frontend = MakeMockFrontend();
1041 AppCacheHost* host = MakeHost(1, frontend); 1041 AppCacheHost* host = MakeHost(1, frontend);
1042 update->StartUpdate(host, GURL::EmptyGURL()); 1042 update->StartUpdate(host, GURL());
1043 EXPECT_TRUE(update->manifest_url_request_ != NULL); 1043 EXPECT_TRUE(update->manifest_url_request_ != NULL);
1044 1044
1045 // Set up checks for when update job finishes. 1045 // Set up checks for when update job finishes.
1046 do_checks_after_update_finished_ = true; 1046 do_checks_after_update_finished_ = true;
1047 expect_group_obsolete_ = false; 1047 expect_group_obsolete_ = false;
1048 expect_group_has_cache_ = false; // 404 explicit url is cache failure 1048 expect_group_has_cache_ = false; // 404 explicit url is cache failure
1049 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), 1049 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
1050 CHECKING_EVENT); 1050 CHECKING_EVENT);
1051 1051
1052 WaitForUpdateToFinish(); 1052 WaitForUpdateToFinish();
(...skipping 10 matching lines...) Expand all
1063 group_->update_job_ = update; 1063 group_->update_job_ = update;
1064 1064
1065 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 99); 1065 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 99);
1066 MockFrontend* frontend1 = MakeMockFrontend(); 1066 MockFrontend* frontend1 = MakeMockFrontend();
1067 MockFrontend* frontend2 = MakeMockFrontend(); 1067 MockFrontend* frontend2 = MakeMockFrontend();
1068 AppCacheHost* host1 = MakeHost(1, frontend1); 1068 AppCacheHost* host1 = MakeHost(1, frontend1);
1069 AppCacheHost* host2 = MakeHost(2, frontend2); 1069 AppCacheHost* host2 = MakeHost(2, frontend2);
1070 host1->AssociateCache(cache); 1070 host1->AssociateCache(cache);
1071 host2->AssociateCache(cache); 1071 host2->AssociateCache(cache);
1072 1072
1073 update->StartUpdate(NULL, GURL::EmptyGURL()); 1073 update->StartUpdate(NULL, GURL());
1074 EXPECT_TRUE(update->manifest_url_request_ != NULL); 1074 EXPECT_TRUE(update->manifest_url_request_ != NULL);
1075 1075
1076 // Set up checks for when update job finishes. 1076 // Set up checks for when update job finishes.
1077 do_checks_after_update_finished_ = true; 1077 do_checks_after_update_finished_ = true;
1078 expect_group_obsolete_ = false; 1078 expect_group_obsolete_ = false;
1079 expect_group_has_cache_ = true; 1079 expect_group_has_cache_ = true;
1080 expect_newest_cache_ = cache; // newest cache unaffectd by failed update 1080 expect_newest_cache_ = cache; // newest cache unaffectd by failed update
1081 MockFrontend::HostIds ids1(1, host1->host_id()); 1081 MockFrontend::HostIds ids1(1, host1->host_id());
1082 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT); 1082 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
1083 frontend1->AddExpectedEvent(ids1, DOWNLOADING_EVENT); 1083 frontend1->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 cache->AddEntry( 1118 cache->AddEntry(
1119 http_server_->TestServerPage("files/notfound"), 1119 http_server_->TestServerPage("files/notfound"),
1120 AppCacheEntry(AppCacheEntry::MASTER, 222)); 1120 AppCacheEntry(AppCacheEntry::MASTER, 222));
1121 cache->AddEntry( 1121 cache->AddEntry(
1122 http_server_->TestServerPage("files/explicit2"), 1122 http_server_->TestServerPage("files/explicit2"),
1123 AppCacheEntry(AppCacheEntry::MASTER | AppCacheEntry::FOREIGN, 333)); 1123 AppCacheEntry(AppCacheEntry::MASTER | AppCacheEntry::FOREIGN, 333));
1124 cache->AddEntry( 1124 cache->AddEntry(
1125 http_server_->TestServerPage("files/servererror"), 1125 http_server_->TestServerPage("files/servererror"),
1126 AppCacheEntry(AppCacheEntry::MASTER, 444)); 1126 AppCacheEntry(AppCacheEntry::MASTER, 444));
1127 1127
1128 update->StartUpdate(NULL, GURL::EmptyGURL()); 1128 update->StartUpdate(NULL, GURL());
1129 EXPECT_TRUE(update->manifest_url_request_ != NULL); 1129 EXPECT_TRUE(update->manifest_url_request_ != NULL);
1130 1130
1131 // Set up checks for when update job finishes. 1131 // Set up checks for when update job finishes.
1132 do_checks_after_update_finished_ = true; 1132 do_checks_after_update_finished_ = true;
1133 expect_group_obsolete_ = false; 1133 expect_group_obsolete_ = false;
1134 expect_group_has_cache_ = true; 1134 expect_group_has_cache_ = true;
1135 expect_old_cache_ = cache; 1135 expect_old_cache_ = cache;
1136 tested_manifest_ = MANIFEST1; 1136 tested_manifest_ = MANIFEST1;
1137 expect_extra_entries_.insert(AppCache::EntryMap::value_type( 1137 expect_extra_entries_.insert(AppCache::EntryMap::value_type(
1138 http_server_->TestServerPage("files/explicit2"), 1138 http_server_->TestServerPage("files/explicit2"),
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 group_->update_job_ = update; 1181 group_->update_job_ = update;
1182 1182
1183 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 33); 1183 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 33);
1184 MockFrontend* frontend1 = MakeMockFrontend(); 1184 MockFrontend* frontend1 = MakeMockFrontend();
1185 MockFrontend* frontend2 = MakeMockFrontend(); 1185 MockFrontend* frontend2 = MakeMockFrontend();
1186 AppCacheHost* host1 = MakeHost(1, frontend1); 1186 AppCacheHost* host1 = MakeHost(1, frontend1);
1187 AppCacheHost* host2 = MakeHost(2, frontend2); 1187 AppCacheHost* host2 = MakeHost(2, frontend2);
1188 host1->AssociateCache(cache); 1188 host1->AssociateCache(cache);
1189 host2->AssociateCache(cache); 1189 host2->AssociateCache(cache);
1190 1190
1191 update->StartUpdate(NULL, GURL::EmptyGURL()); 1191 update->StartUpdate(NULL, GURL());
1192 EXPECT_TRUE(update->manifest_url_request_ != NULL); 1192 EXPECT_TRUE(update->manifest_url_request_ != NULL);
1193 1193
1194 // Set up checks for when update job finishes. 1194 // Set up checks for when update job finishes.
1195 do_checks_after_update_finished_ = true; 1195 do_checks_after_update_finished_ = true;
1196 expect_group_obsolete_ = false; 1196 expect_group_obsolete_ = false;
1197 expect_group_has_cache_ = true; 1197 expect_group_has_cache_ = true;
1198 expect_old_cache_ = cache; 1198 expect_old_cache_ = cache;
1199 tested_manifest_ = EMPTY_MANIFEST; 1199 tested_manifest_ = EMPTY_MANIFEST;
1200 MockFrontend::HostIds ids1(1, host1->host_id()); 1200 MockFrontend::HostIds ids1(1, host1->host_id());
1201 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT); 1201 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
(...skipping 15 matching lines...) Expand all
1217 http_server_->TestServerPage("files/empty-file-manifest"), 1217 http_server_->TestServerPage("files/empty-file-manifest"),
1218 service_->storage()->NewGroupId()); 1218 service_->storage()->NewGroupId());
1219 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 1219 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
1220 group_->update_job_ = update; 1220 group_->update_job_ = update;
1221 1221
1222 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 22); 1222 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 22);
1223 MockFrontend* frontend = MakeMockFrontend(); 1223 MockFrontend* frontend = MakeMockFrontend();
1224 AppCacheHost* host = MakeHost(1, frontend); 1224 AppCacheHost* host = MakeHost(1, frontend);
1225 host->AssociateCache(cache); 1225 host->AssociateCache(cache);
1226 1226
1227 update->StartUpdate(host, GURL::EmptyGURL()); 1227 update->StartUpdate(host, GURL());
1228 EXPECT_TRUE(update->manifest_url_request_ != NULL); 1228 EXPECT_TRUE(update->manifest_url_request_ != NULL);
1229 1229
1230 // Set up checks for when update job finishes. 1230 // Set up checks for when update job finishes.
1231 do_checks_after_update_finished_ = true; 1231 do_checks_after_update_finished_ = true;
1232 expect_group_obsolete_ = false; 1232 expect_group_obsolete_ = false;
1233 expect_group_has_cache_ = true; 1233 expect_group_has_cache_ = true;
1234 tested_manifest_ = EMPTY_FILE_MANIFEST; 1234 tested_manifest_ = EMPTY_FILE_MANIFEST;
1235 MockFrontend::HostIds ids1(1, host->host_id()); 1235 MockFrontend::HostIds ids1(1, host->host_id());
1236 frontend->AddExpectedEvent(ids1, CHECKING_EVENT); 1236 frontend->AddExpectedEvent(ids1, CHECKING_EVENT);
1237 frontend->AddExpectedEvent(ids1, DOWNLOADING_EVENT); 1237 frontend->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
(...skipping 14 matching lines...) Expand all
1252 registered_factory_ = true; 1252 registered_factory_ = true;
1253 1253
1254 MakeService(); 1254 MakeService();
1255 group_ = new AppCacheGroup(service_.get(), RetryRequestTestJob::kRetryUrl, 1255 group_ = new AppCacheGroup(service_.get(), RetryRequestTestJob::kRetryUrl,
1256 service_->storage()->NewGroupId()); 1256 service_->storage()->NewGroupId());
1257 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 1257 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
1258 group_->update_job_ = update; 1258 group_->update_job_ = update;
1259 1259
1260 MockFrontend* frontend = MakeMockFrontend(); 1260 MockFrontend* frontend = MakeMockFrontend();
1261 AppCacheHost* host = MakeHost(1, frontend); 1261 AppCacheHost* host = MakeHost(1, frontend);
1262 update->StartUpdate(host, GURL::EmptyGURL()); 1262 update->StartUpdate(host, GURL());
1263 EXPECT_TRUE(update->manifest_url_request_ != NULL); 1263 EXPECT_TRUE(update->manifest_url_request_ != NULL);
1264 1264
1265 // Set up checks for when update job finishes. 1265 // Set up checks for when update job finishes.
1266 do_checks_after_update_finished_ = true; 1266 do_checks_after_update_finished_ = true;
1267 expect_group_obsolete_ = false; 1267 expect_group_obsolete_ = false;
1268 expect_group_has_cache_ = false; 1268 expect_group_has_cache_ = false;
1269 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), 1269 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
1270 CHECKING_EVENT); 1270 CHECKING_EVENT);
1271 1271
1272 WaitForUpdateToFinish(); 1272 WaitForUpdateToFinish();
(...skipping 10 matching lines...) Expand all
1283 registered_factory_ = true; 1283 registered_factory_ = true;
1284 1284
1285 MakeService(); 1285 MakeService();
1286 group_ = new AppCacheGroup(service_.get(), RetryRequestTestJob::kRetryUrl, 1286 group_ = new AppCacheGroup(service_.get(), RetryRequestTestJob::kRetryUrl,
1287 service_->storage()->NewGroupId()); 1287 service_->storage()->NewGroupId());
1288 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 1288 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
1289 group_->update_job_ = update; 1289 group_->update_job_ = update;
1290 1290
1291 MockFrontend* frontend = MakeMockFrontend(); 1291 MockFrontend* frontend = MakeMockFrontend();
1292 AppCacheHost* host = MakeHost(1, frontend); 1292 AppCacheHost* host = MakeHost(1, frontend);
1293 update->StartUpdate(host, GURL::EmptyGURL()); 1293 update->StartUpdate(host, GURL());
1294 EXPECT_TRUE(update->manifest_url_request_ != NULL); 1294 EXPECT_TRUE(update->manifest_url_request_ != NULL);
1295 1295
1296 // Set up checks for when update job finishes. 1296 // Set up checks for when update job finishes.
1297 do_checks_after_update_finished_ = true; 1297 do_checks_after_update_finished_ = true;
1298 expect_group_obsolete_ = false; 1298 expect_group_obsolete_ = false;
1299 expect_group_has_cache_ = false; 1299 expect_group_has_cache_ = false;
1300 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), 1300 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
1301 CHECKING_EVENT); 1301 CHECKING_EVENT);
1302 1302
1303 WaitForUpdateToFinish(); 1303 WaitForUpdateToFinish();
(...skipping 11 matching lines...) Expand all
1315 registered_factory_ = true; 1315 registered_factory_ = true;
1316 1316
1317 MakeService(); 1317 MakeService();
1318 group_ = new AppCacheGroup(service_.get(), RetryRequestTestJob::kRetryUrl, 1318 group_ = new AppCacheGroup(service_.get(), RetryRequestTestJob::kRetryUrl,
1319 service_->storage()->NewGroupId()); 1319 service_->storage()->NewGroupId());
1320 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 1320 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
1321 group_->update_job_ = update; 1321 group_->update_job_ = update;
1322 1322
1323 MockFrontend* frontend = MakeMockFrontend(); 1323 MockFrontend* frontend = MakeMockFrontend();
1324 AppCacheHost* host = MakeHost(1, frontend); 1324 AppCacheHost* host = MakeHost(1, frontend);
1325 update->StartUpdate(host, GURL::EmptyGURL()); 1325 update->StartUpdate(host, GURL());
1326 EXPECT_TRUE(update->manifest_url_request_ != NULL); 1326 EXPECT_TRUE(update->manifest_url_request_ != NULL);
1327 1327
1328 // Set up checks for when update job finishes. 1328 // Set up checks for when update job finishes.
1329 do_checks_after_update_finished_ = true; 1329 do_checks_after_update_finished_ = true;
1330 expect_group_obsolete_ = false; 1330 expect_group_obsolete_ = false;
1331 expect_group_has_cache_ = false; 1331 expect_group_has_cache_ = false;
1332 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), 1332 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
1333 CHECKING_EVENT); 1333 CHECKING_EVENT);
1334 1334
1335 WaitForUpdateToFinish(); 1335 WaitForUpdateToFinish();
(...skipping 10 matching lines...) Expand all
1346 registered_factory_ = true; 1346 registered_factory_ = true;
1347 1347
1348 MakeService(); 1348 MakeService();
1349 group_ = new AppCacheGroup(service_.get(), RetryRequestTestJob::kRetryUrl, 1349 group_ = new AppCacheGroup(service_.get(), RetryRequestTestJob::kRetryUrl,
1350 service_->storage()->NewGroupId()); 1350 service_->storage()->NewGroupId());
1351 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 1351 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
1352 group_->update_job_ = update; 1352 group_->update_job_ = update;
1353 1353
1354 MockFrontend* frontend = MakeMockFrontend(); 1354 MockFrontend* frontend = MakeMockFrontend();
1355 AppCacheHost* host = MakeHost(1, frontend); 1355 AppCacheHost* host = MakeHost(1, frontend);
1356 update->StartUpdate(host, GURL::EmptyGURL()); 1356 update->StartUpdate(host, GURL());
1357 EXPECT_TRUE(update->manifest_url_request_ != NULL); 1357 EXPECT_TRUE(update->manifest_url_request_ != NULL);
1358 1358
1359 // Set up checks for when update job finishes. 1359 // Set up checks for when update job finishes.
1360 do_checks_after_update_finished_ = true; 1360 do_checks_after_update_finished_ = true;
1361 expect_group_obsolete_ = false; 1361 expect_group_obsolete_ = false;
1362 expect_group_has_cache_ = true; 1362 expect_group_has_cache_ = true;
1363 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), 1363 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
1364 CHECKING_EVENT); 1364 CHECKING_EVENT);
1365 1365
1366 WaitForUpdateToFinish(); 1366 WaitForUpdateToFinish();
(...skipping 10 matching lines...) Expand all
1377 registered_factory_ = true; 1377 registered_factory_ = true;
1378 1378
1379 MakeService(); 1379 MakeService();
1380 group_ = new AppCacheGroup(service_.get(), GURL("http://retryurl"), 1380 group_ = new AppCacheGroup(service_.get(), GURL("http://retryurl"),
1381 service_->storage()->NewGroupId()); 1381 service_->storage()->NewGroupId());
1382 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 1382 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
1383 group_->update_job_ = update; 1383 group_->update_job_ = update;
1384 1384
1385 MockFrontend* frontend = MakeMockFrontend(); 1385 MockFrontend* frontend = MakeMockFrontend();
1386 AppCacheHost* host = MakeHost(1, frontend); 1386 AppCacheHost* host = MakeHost(1, frontend);
1387 update->StartUpdate(host, GURL::EmptyGURL()); 1387 update->StartUpdate(host, GURL());
1388 EXPECT_TRUE(update->manifest_url_request_ != NULL); 1388 EXPECT_TRUE(update->manifest_url_request_ != NULL);
1389 1389
1390 // Set up checks for when update job finishes. 1390 // Set up checks for when update job finishes.
1391 do_checks_after_update_finished_ = true; 1391 do_checks_after_update_finished_ = true;
1392 expect_group_obsolete_ = false; 1392 expect_group_obsolete_ = false;
1393 expect_group_has_cache_ = true; 1393 expect_group_has_cache_ = true;
1394 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), 1394 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
1395 CHECKING_EVENT); 1395 CHECKING_EVENT);
1396 1396
1397 WaitForUpdateToFinish(); 1397 WaitForUpdateToFinish();
1398 } 1398 }
1399 1399
1400 void FailStoreNewestCacheTest() { 1400 void FailStoreNewestCacheTest() {
1401 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); 1401 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type());
1402 1402
1403 MakeService(); 1403 MakeService();
1404 MockAppCacheStorage* storage = 1404 MockAppCacheStorage* storage =
1405 reinterpret_cast<MockAppCacheStorage*>(service_->storage()); 1405 reinterpret_cast<MockAppCacheStorage*>(service_->storage());
1406 storage->SimulateStoreGroupAndNewestCacheFailure(); 1406 storage->SimulateStoreGroupAndNewestCacheFailure();
1407 1407
1408 group_ = new AppCacheGroup( 1408 group_ = new AppCacheGroup(
1409 service_.get(), http_server_->TestServerPage("files/manifest1"), 1409 service_.get(), http_server_->TestServerPage("files/manifest1"),
1410 service_->storage()->NewGroupId()); 1410 service_->storage()->NewGroupId());
1411 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 1411 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
1412 group_->update_job_ = update; 1412 group_->update_job_ = update;
1413 1413
1414 MockFrontend* frontend = MakeMockFrontend(); 1414 MockFrontend* frontend = MakeMockFrontend();
1415 AppCacheHost* host = MakeHost(1, frontend); 1415 AppCacheHost* host = MakeHost(1, frontend);
1416 update->StartUpdate(host, GURL::EmptyGURL()); 1416 update->StartUpdate(host, GURL());
1417 1417
1418 // Set up checks for when update job finishes. 1418 // Set up checks for when update job finishes.
1419 do_checks_after_update_finished_ = true; 1419 do_checks_after_update_finished_ = true;
1420 expect_group_obsolete_ = false; 1420 expect_group_obsolete_ = false;
1421 expect_group_has_cache_ = false; // storage failed 1421 expect_group_has_cache_ = false; // storage failed
1422 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), 1422 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
1423 CHECKING_EVENT); 1423 CHECKING_EVENT);
1424 1424
1425 WaitForUpdateToFinish(); 1425 WaitForUpdateToFinish();
1426 } 1426 }
(...skipping 13 matching lines...) Expand all
1440 group_->update_job_ = update; 1440 group_->update_job_ = update;
1441 1441
1442 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 11); 1442 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 11);
1443 MockFrontend* frontend1 = MakeMockFrontend(); 1443 MockFrontend* frontend1 = MakeMockFrontend();
1444 MockFrontend* frontend2 = MakeMockFrontend(); 1444 MockFrontend* frontend2 = MakeMockFrontend();
1445 AppCacheHost* host1 = MakeHost(1, frontend1); 1445 AppCacheHost* host1 = MakeHost(1, frontend1);
1446 AppCacheHost* host2 = MakeHost(2, frontend2); 1446 AppCacheHost* host2 = MakeHost(2, frontend2);
1447 host1->AssociateCache(cache); 1447 host1->AssociateCache(cache);
1448 host2->AssociateCache(cache); 1448 host2->AssociateCache(cache);
1449 1449
1450 update->StartUpdate(NULL, GURL::EmptyGURL()); 1450 update->StartUpdate(NULL, GURL());
1451 1451
1452 // Set up checks for when update job finishes. 1452 // Set up checks for when update job finishes.
1453 do_checks_after_update_finished_ = true; 1453 do_checks_after_update_finished_ = true;
1454 expect_group_obsolete_ = false; 1454 expect_group_obsolete_ = false;
1455 expect_group_has_cache_ = true; 1455 expect_group_has_cache_ = true;
1456 expect_newest_cache_ = cache; // unchanged 1456 expect_newest_cache_ = cache; // unchanged
1457 MockFrontend::HostIds ids1(1, host1->host_id()); 1457 MockFrontend::HostIds ids1(1, host1->host_id());
1458 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT); 1458 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
1459 frontend1->AddExpectedEvent(ids1, DOWNLOADING_EVENT); 1459 frontend1->AddExpectedEvent(ids1, DOWNLOADING_EVENT);
1460 frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT); 1460 frontend1->AddExpectedEvent(ids1, PROGRESS_EVENT);
(...skipping 18 matching lines...) Expand all
1479 storage->SimulateMakeGroupObsoleteFailure(); 1479 storage->SimulateMakeGroupObsoleteFailure();
1480 1480
1481 group_ = new AppCacheGroup( 1481 group_ = new AppCacheGroup(
1482 service_.get(), http_server_->TestServerPage("files/gone"), 1482 service_.get(), http_server_->TestServerPage("files/gone"),
1483 service_->storage()->NewGroupId()); 1483 service_->storage()->NewGroupId());
1484 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 1484 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
1485 group_->update_job_ = update; 1485 group_->update_job_ = update;
1486 1486
1487 MockFrontend* frontend = MakeMockFrontend(); 1487 MockFrontend* frontend = MakeMockFrontend();
1488 AppCacheHost* host = MakeHost(1, frontend); 1488 AppCacheHost* host = MakeHost(1, frontend);
1489 update->StartUpdate(host, GURL::EmptyGURL()); 1489 update->StartUpdate(host, GURL());
1490 EXPECT_TRUE(update->manifest_url_request_ != NULL); 1490 EXPECT_TRUE(update->manifest_url_request_ != NULL);
1491 1491
1492 // Set up checks for when update job finishes. 1492 // Set up checks for when update job finishes.
1493 do_checks_after_update_finished_ = true; 1493 do_checks_after_update_finished_ = true;
1494 expect_group_obsolete_ = false; 1494 expect_group_obsolete_ = false;
1495 expect_group_has_cache_ = false; 1495 expect_group_has_cache_ = false;
1496 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), 1496 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()),
1497 CHECKING_EVENT); 1497 CHECKING_EVENT);
1498 1498
1499 WaitForUpdateToFinish(); 1499 WaitForUpdateToFinish();
(...skipping 14 matching lines...) Expand all
1514 group_->update_job_ = update; 1514 group_->update_job_ = update;
1515 1515
1516 AppCache* cache = MakeCacheForGroup(1, 111); 1516 AppCache* cache = MakeCacheForGroup(1, 111);
1517 MockFrontend* frontend1 = MakeMockFrontend(); 1517 MockFrontend* frontend1 = MakeMockFrontend();
1518 MockFrontend* frontend2 = MakeMockFrontend(); 1518 MockFrontend* frontend2 = MakeMockFrontend();
1519 AppCacheHost* host1 = MakeHost(1, frontend1); 1519 AppCacheHost* host1 = MakeHost(1, frontend1);
1520 AppCacheHost* host2 = MakeHost(2, frontend2); 1520 AppCacheHost* host2 = MakeHost(2, frontend2);
1521 host1->AssociateCache(cache); 1521 host1->AssociateCache(cache);
1522 host2->AssociateCache(cache); 1522 host2->AssociateCache(cache);
1523 1523
1524 update->StartUpdate(NULL, GURL::EmptyGURL()); 1524 update->StartUpdate(NULL, GURL());
1525 EXPECT_TRUE(update->manifest_url_request_ != NULL); 1525 EXPECT_TRUE(update->manifest_url_request_ != NULL);
1526 1526
1527 // Set up checks for when update job finishes. 1527 // Set up checks for when update job finishes.
1528 do_checks_after_update_finished_ = true; 1528 do_checks_after_update_finished_ = true;
1529 expect_group_obsolete_ = false; 1529 expect_group_obsolete_ = false;
1530 expect_group_has_cache_ = true; 1530 expect_group_has_cache_ = true;
1531 expect_newest_cache_ = cache; // newest cache unaffected by update 1531 expect_newest_cache_ = cache; // newest cache unaffected by update
1532 MockFrontend::HostIds ids1(1, host1->host_id()); 1532 MockFrontend::HostIds ids1(1, host1->host_id());
1533 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT); 1533 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT);
1534 frontend1->AddExpectedEvent(ids1, ERROR_EVENT); 1534 frontend1->AddExpectedEvent(ids1, ERROR_EVENT);
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
2065 group_ = new AppCacheGroup( 2065 group_ = new AppCacheGroup(
2066 service_.get(), http_server_->TestServerPage("files/manifest1"), 111); 2066 service_.get(), http_server_->TestServerPage("files/manifest1"), 111);
2067 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 2067 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
2068 group_->update_job_ = update; 2068 group_->update_job_ = update;
2069 2069
2070 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 42); 2070 AppCache* cache = MakeCacheForGroup(service_->storage()->NewCacheId(), 42);
2071 MockFrontend* frontend1 = MakeMockFrontend(); 2071 MockFrontend* frontend1 = MakeMockFrontend();
2072 AppCacheHost* host1 = MakeHost(1, frontend1); 2072 AppCacheHost* host1 = MakeHost(1, frontend1);
2073 host1->AssociateCache(cache); 2073 host1->AssociateCache(cache);
2074 2074
2075 update->StartUpdate(NULL, GURL::EmptyGURL()); 2075 update->StartUpdate(NULL, GURL());
2076 2076
2077 // Set up additional updates to be started while update is in progress. 2077 // Set up additional updates to be started while update is in progress.
2078 MockFrontend* frontend2 = MakeMockFrontend(); 2078 MockFrontend* frontend2 = MakeMockFrontend();
2079 AppCacheHost* host2 = MakeHost(2, frontend2); 2079 AppCacheHost* host2 = MakeHost(2, frontend2);
2080 host2->new_master_entry_url_ = 2080 host2->new_master_entry_url_ =
2081 http_server_->TestServerPage("files/explicit1"); 2081 http_server_->TestServerPage("files/explicit1");
2082 2082
2083 MockFrontend* frontend3 = MakeMockFrontend(); 2083 MockFrontend* frontend3 = MakeMockFrontend();
2084 AppCacheHost* host3 = MakeHost(3, frontend3); 2084 AppCacheHost* host3 = MakeHost(3, frontend3);
2085 host3->new_master_entry_url_ = 2085 host3->new_master_entry_url_ =
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
2192 MakeService(); 2192 MakeService();
2193 group_ = new AppCacheGroup(service_.get(), GURL("http://headertest"), 111); 2193 group_ = new AppCacheGroup(service_.get(), GURL("http://headertest"), 111);
2194 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); 2194 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_);
2195 group_->update_job_ = update; 2195 group_->update_job_ = update;
2196 2196
2197 // First test against a cache attempt. Will start manifest fetch 2197 // First test against a cache attempt. Will start manifest fetch
2198 // synchronously. 2198 // synchronously.
2199 HttpHeadersRequestTestJob::Initialize("", ""); 2199 HttpHeadersRequestTestJob::Initialize("", "");
2200 MockFrontend mock_frontend; 2200 MockFrontend mock_frontend;
2201 AppCacheHost host(1, &mock_frontend, service_.get()); 2201 AppCacheHost host(1, &mock_frontend, service_.get());
2202 update->StartUpdate(&host, GURL::EmptyGURL()); 2202 update->StartUpdate(&host, GURL());
2203 HttpHeadersRequestTestJob::Verify(); 2203 HttpHeadersRequestTestJob::Verify();
2204 delete update; 2204 delete update;
2205 2205
2206 // Now simulate a refetch manifest request. Will start fetch request 2206 // Now simulate a refetch manifest request. Will start fetch request
2207 // synchronously. 2207 // synchronously.
2208 const char data[] = 2208 const char data[] =
2209 "HTTP/1.1 200 OK\0" 2209 "HTTP/1.1 200 OK\0"
2210 "\0"; 2210 "\0";
2211 net::HttpResponseHeaders* headers = 2211 net::HttpResponseHeaders* headers =
2212 new net::HttpResponseHeaders(std::string(data, arraysize(data))); 2212 new net::HttpResponseHeaders(std::string(data, arraysize(data)));
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
2794 scoped_refptr<AppCacheGroup> group = 2794 scoped_refptr<AppCacheGroup> group =
2795 new AppCacheGroup(&service, GURL("http://manifesturl.com"), 2795 new AppCacheGroup(&service, GURL("http://manifesturl.com"),
2796 service.storage()->NewGroupId()); 2796 service.storage()->NewGroupId());
2797 2797
2798 AppCacheUpdateJob update(&service, group); 2798 AppCacheUpdateJob update(&service, group);
2799 2799
2800 // Pretend group is in checking state. 2800 // Pretend group is in checking state.
2801 group->update_job_ = &update; 2801 group->update_job_ = &update;
2802 group->update_status_ = AppCacheGroup::CHECKING; 2802 group->update_status_ = AppCacheGroup::CHECKING;
2803 2803
2804 update.StartUpdate(NULL, GURL::EmptyGURL()); 2804 update.StartUpdate(NULL, GURL());
2805 EXPECT_EQ(AppCacheGroup::CHECKING, group->update_status()); 2805 EXPECT_EQ(AppCacheGroup::CHECKING, group->update_status());
2806 2806
2807 MockFrontend mock_frontend; 2807 MockFrontend mock_frontend;
2808 AppCacheHost host(1, &mock_frontend, &service); 2808 AppCacheHost host(1, &mock_frontend, &service);
2809 update.StartUpdate(&host, GURL::EmptyGURL()); 2809 update.StartUpdate(&host, GURL());
2810 2810
2811 MockFrontend::RaisedEvents events = mock_frontend.raised_events_; 2811 MockFrontend::RaisedEvents events = mock_frontend.raised_events_;
2812 size_t expected = 1; 2812 size_t expected = 1;
2813 EXPECT_EQ(expected, events.size()); 2813 EXPECT_EQ(expected, events.size());
2814 EXPECT_EQ(expected, events[0].first.size()); 2814 EXPECT_EQ(expected, events[0].first.size());
2815 EXPECT_EQ(host.host_id(), events[0].first[0]); 2815 EXPECT_EQ(host.host_id(), events[0].first[0]);
2816 EXPECT_EQ(CHECKING_EVENT, events[0].second); 2816 EXPECT_EQ(CHECKING_EVENT, events[0].second);
2817 EXPECT_EQ(AppCacheGroup::CHECKING, group->update_status()); 2817 EXPECT_EQ(AppCacheGroup::CHECKING, group->update_status());
2818 } 2818 }
2819 2819
2820 TEST_F(AppCacheUpdateJobTest, AlreadyDownloading) { 2820 TEST_F(AppCacheUpdateJobTest, AlreadyDownloading) {
2821 MockAppCacheService service; 2821 MockAppCacheService service;
2822 scoped_refptr<AppCacheGroup> group = 2822 scoped_refptr<AppCacheGroup> group =
2823 new AppCacheGroup(&service, GURL("http://manifesturl.com"), 2823 new AppCacheGroup(&service, GURL("http://manifesturl.com"),
2824 service.storage()->NewGroupId()); 2824 service.storage()->NewGroupId());
2825 2825
2826 AppCacheUpdateJob update(&service, group); 2826 AppCacheUpdateJob update(&service, group);
2827 2827
2828 // Pretend group is in downloading state. 2828 // Pretend group is in downloading state.
2829 group->update_job_ = &update; 2829 group->update_job_ = &update;
2830 group->update_status_ = AppCacheGroup::DOWNLOADING; 2830 group->update_status_ = AppCacheGroup::DOWNLOADING;
2831 2831
2832 update.StartUpdate(NULL, GURL::EmptyGURL()); 2832 update.StartUpdate(NULL, GURL());
2833 EXPECT_EQ(AppCacheGroup::DOWNLOADING, group->update_status()); 2833 EXPECT_EQ(AppCacheGroup::DOWNLOADING, group->update_status());
2834 2834
2835 MockFrontend mock_frontend; 2835 MockFrontend mock_frontend;
2836 AppCacheHost host(1, &mock_frontend, &service); 2836 AppCacheHost host(1, &mock_frontend, &service);
2837 update.StartUpdate(&host, GURL::EmptyGURL()); 2837 update.StartUpdate(&host, GURL());
2838 2838
2839 MockFrontend::RaisedEvents events = mock_frontend.raised_events_; 2839 MockFrontend::RaisedEvents events = mock_frontend.raised_events_;
2840 size_t expected = 2; 2840 size_t expected = 2;
2841 EXPECT_EQ(expected, events.size()); 2841 EXPECT_EQ(expected, events.size());
2842 expected = 1; 2842 expected = 1;
2843 EXPECT_EQ(expected, events[0].first.size()); 2843 EXPECT_EQ(expected, events[0].first.size());
2844 EXPECT_EQ(host.host_id(), events[0].first[0]); 2844 EXPECT_EQ(host.host_id(), events[0].first[0]);
2845 EXPECT_EQ(CHECKING_EVENT, events[0].second); 2845 EXPECT_EQ(CHECKING_EVENT, events[0].second);
2846 2846
2847 EXPECT_EQ(expected, events[1].first.size()); 2847 EXPECT_EQ(expected, events[1].first.size());
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
3042 3042
3043 TEST_F(AppCacheUpdateJobTest, IfNoneMatchRefetch) { 3043 TEST_F(AppCacheUpdateJobTest, IfNoneMatchRefetch) {
3044 RunTestOnIOThread(&AppCacheUpdateJobTest::IfNoneMatchRefetchTest); 3044 RunTestOnIOThread(&AppCacheUpdateJobTest::IfNoneMatchRefetchTest);
3045 } 3045 }
3046 3046
3047 TEST_F(AppCacheUpdateJobTest, MultipleHeadersRefetch) { 3047 TEST_F(AppCacheUpdateJobTest, MultipleHeadersRefetch) {
3048 RunTestOnIOThread(&AppCacheUpdateJobTest::MultipleHeadersRefetchTest); 3048 RunTestOnIOThread(&AppCacheUpdateJobTest::MultipleHeadersRefetchTest);
3049 } 3049 }
3050 3050
3051 } // namespace appcache 3051 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_storage_unittest.cc ('k') | webkit/appcache/appcache_url_request_job_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698