OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 storage()->LazyInitialize(base::Bind(&base::DoNothing)); | 554 storage()->LazyInitialize(base::Bind(&base::DoNothing)); |
555 base::RunLoop().RunUntilIdle(); | 555 base::RunLoop().RunUntilIdle(); |
556 scope_ = GURL("http://www.test.not/scope/"); | 556 scope_ = GURL("http://www.test.not/scope/"); |
557 script_ = GURL("http://www.test.not/script.js"); | 557 script_ = GURL("http://www.test.not/script.js"); |
558 import_ = GURL("http://www.test.not/import.js"); | 558 import_ = GURL("http://www.test.not/import.js"); |
559 document_url_ = GURL("http://www.test.not/scope/document.html"); | 559 document_url_ = GURL("http://www.test.not/scope/document.html"); |
560 registration_id_ = storage()->NewRegistrationId(); | 560 registration_id_ = storage()->NewRegistrationId(); |
561 version_id_ = storage()->NewVersionId(); | 561 version_id_ = storage()->NewVersionId(); |
562 resource_id1_ = storage()->NewResourceId(); | 562 resource_id1_ = storage()->NewResourceId(); |
563 resource_id2_ = storage()->NewResourceId(); | 563 resource_id2_ = storage()->NewResourceId(); |
| 564 resource_id1_size_ = 239193; |
| 565 resource_id2_size_ = 59923; |
564 | 566 |
565 // Cons up a new registration+version with two script resources. | 567 // Cons up a new registration+version with two script resources. |
566 RegistrationData data; | 568 RegistrationData data; |
567 data.registration_id = registration_id_; | 569 data.registration_id = registration_id_; |
568 data.scope = scope_; | 570 data.scope = scope_; |
569 data.script = script_; | 571 data.script = script_; |
570 data.version_id = version_id_; | 572 data.version_id = version_id_; |
571 data.is_active = false; | 573 data.is_active = false; |
572 std::vector<ResourceRecord> resources; | 574 std::vector<ResourceRecord> resources; |
573 resources.push_back(ResourceRecord(resource_id1_, script_)); | 575 resources.push_back( |
574 resources.push_back(ResourceRecord(resource_id2_, import_)); | 576 ResourceRecord(resource_id1_, script_, resource_id1_size_)); |
| 577 resources.push_back( |
| 578 ResourceRecord(resource_id2_, import_, resource_id2_size_)); |
575 registration_ = storage()->GetOrCreateRegistration(data, resources); | 579 registration_ = storage()->GetOrCreateRegistration(data, resources); |
576 registration_->waiting_version()->SetStatus(ServiceWorkerVersion::NEW); | 580 registration_->waiting_version()->SetStatus(ServiceWorkerVersion::NEW); |
577 | 581 |
578 // Add the resources ids to the uncommitted list. | 582 // Add the resources ids to the uncommitted list. |
579 storage()->StoreUncommittedResponseId(resource_id1_); | 583 storage()->StoreUncommittedResponseId(resource_id1_); |
580 storage()->StoreUncommittedResponseId(resource_id2_); | 584 storage()->StoreUncommittedResponseId(resource_id2_); |
581 base::RunLoop().RunUntilIdle(); | 585 base::RunLoop().RunUntilIdle(); |
582 std::set<int64> verify_ids; | 586 std::set<int64> verify_ids; |
583 EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, | 587 EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, |
584 storage()->database_->GetUncommittedResourceIds(&verify_ids)); | 588 storage()->database_->GetUncommittedResourceIds(&verify_ids)); |
(...skipping 17 matching lines...) Expand all Loading... |
602 } | 606 } |
603 | 607 |
604 protected: | 608 protected: |
605 GURL scope_; | 609 GURL scope_; |
606 GURL script_; | 610 GURL script_; |
607 GURL import_; | 611 GURL import_; |
608 GURL document_url_; | 612 GURL document_url_; |
609 int64 registration_id_; | 613 int64 registration_id_; |
610 int64 version_id_; | 614 int64 version_id_; |
611 int64 resource_id1_; | 615 int64 resource_id1_; |
| 616 uint64 resource_id1_size_; |
612 int64 resource_id2_; | 617 int64 resource_id2_; |
| 618 uint64 resource_id2_size_; |
613 scoped_refptr<ServiceWorkerRegistration> registration_; | 619 scoped_refptr<ServiceWorkerRegistration> registration_; |
614 }; | 620 }; |
615 | 621 |
616 class ServiceWorkerResourceStorageDiskTest | 622 class ServiceWorkerResourceStorageDiskTest |
617 : public ServiceWorkerResourceStorageTest { | 623 : public ServiceWorkerResourceStorageTest { |
618 public: | 624 public: |
619 virtual void SetUp() override { | 625 virtual void SetUp() override { |
620 ASSERT_TRUE(user_data_directory_.CreateUniqueTempDir()); | 626 ASSERT_TRUE(user_data_directory_.CreateUniqueTempDir()); |
621 ServiceWorkerResourceStorageTest::SetUp(); | 627 ServiceWorkerResourceStorageTest::SetUp(); |
622 } | 628 } |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 are_equal = true; | 1052 are_equal = true; |
1047 storage()->CompareScriptResources( | 1053 storage()->CompareScriptResources( |
1048 5, 6, | 1054 5, 6, |
1049 base::Bind(&OnCompareComplete, &status, &are_equal)); | 1055 base::Bind(&OnCompareComplete, &status, &are_equal)); |
1050 base::RunLoop().RunUntilIdle(); | 1056 base::RunLoop().RunUntilIdle(); |
1051 EXPECT_EQ(SERVICE_WORKER_OK, status); | 1057 EXPECT_EQ(SERVICE_WORKER_OK, status); |
1052 EXPECT_FALSE(are_equal); | 1058 EXPECT_FALSE(are_equal); |
1053 } | 1059 } |
1054 | 1060 |
1055 } // namespace content | 1061 } // namespace content |
OLD | NEW |