| 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 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 storage()->LazyInitialize(base::Bind(&base::DoNothing)); | 550 storage()->LazyInitialize(base::Bind(&base::DoNothing)); |
| 551 base::RunLoop().RunUntilIdle(); | 551 base::RunLoop().RunUntilIdle(); |
| 552 scope_ = GURL("http://www.test.not/scope/"); | 552 scope_ = GURL("http://www.test.not/scope/"); |
| 553 script_ = GURL("http://www.test.not/script.js"); | 553 script_ = GURL("http://www.test.not/script.js"); |
| 554 import_ = GURL("http://www.test.not/import.js"); | 554 import_ = GURL("http://www.test.not/import.js"); |
| 555 document_url_ = GURL("http://www.test.not/scope/document.html"); | 555 document_url_ = GURL("http://www.test.not/scope/document.html"); |
| 556 registration_id_ = storage()->NewRegistrationId(); | 556 registration_id_ = storage()->NewRegistrationId(); |
| 557 version_id_ = storage()->NewVersionId(); | 557 version_id_ = storage()->NewVersionId(); |
| 558 resource_id1_ = storage()->NewResourceId(); | 558 resource_id1_ = storage()->NewResourceId(); |
| 559 resource_id2_ = storage()->NewResourceId(); | 559 resource_id2_ = storage()->NewResourceId(); |
| 560 resource_id1_size_ = 239193; |
| 561 resource_id2_size_ = 59923; |
| 560 | 562 |
| 561 // Cons up a new registration+version with two script resources. | 563 // Cons up a new registration+version with two script resources. |
| 562 RegistrationData data; | 564 RegistrationData data; |
| 563 data.registration_id = registration_id_; | 565 data.registration_id = registration_id_; |
| 564 data.scope = scope_; | 566 data.scope = scope_; |
| 565 data.script = script_; | 567 data.script = script_; |
| 566 data.version_id = version_id_; | 568 data.version_id = version_id_; |
| 567 data.is_active = false; | 569 data.is_active = false; |
| 568 std::vector<ResourceRecord> resources; | 570 std::vector<ResourceRecord> resources; |
| 569 resources.push_back(ResourceRecord(resource_id1_, script_)); | 571 resources.push_back( |
| 570 resources.push_back(ResourceRecord(resource_id2_, import_)); | 572 ResourceRecord(resource_id1_, script_, resource_id1_size_)); |
| 573 resources.push_back( |
| 574 ResourceRecord(resource_id2_, import_, resource_id2_size_)); |
| 571 registration_ = storage()->GetOrCreateRegistration(data, resources); | 575 registration_ = storage()->GetOrCreateRegistration(data, resources); |
| 572 registration_->waiting_version()->SetStatus(ServiceWorkerVersion::NEW); | 576 registration_->waiting_version()->SetStatus(ServiceWorkerVersion::NEW); |
| 573 | 577 |
| 574 // Add the resources ids to the uncommitted list. | 578 // Add the resources ids to the uncommitted list. |
| 575 storage()->StoreUncommittedResponseId(resource_id1_); | 579 storage()->StoreUncommittedResponseId(resource_id1_); |
| 576 storage()->StoreUncommittedResponseId(resource_id2_); | 580 storage()->StoreUncommittedResponseId(resource_id2_); |
| 577 base::RunLoop().RunUntilIdle(); | 581 base::RunLoop().RunUntilIdle(); |
| 578 std::set<int64> verify_ids; | 582 std::set<int64> verify_ids; |
| 579 EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, | 583 EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK, |
| 580 storage()->database_->GetUncommittedResourceIds(&verify_ids)); | 584 storage()->database_->GetUncommittedResourceIds(&verify_ids)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 598 } | 602 } |
| 599 | 603 |
| 600 protected: | 604 protected: |
| 601 GURL scope_; | 605 GURL scope_; |
| 602 GURL script_; | 606 GURL script_; |
| 603 GURL import_; | 607 GURL import_; |
| 604 GURL document_url_; | 608 GURL document_url_; |
| 605 int64 registration_id_; | 609 int64 registration_id_; |
| 606 int64 version_id_; | 610 int64 version_id_; |
| 607 int64 resource_id1_; | 611 int64 resource_id1_; |
| 612 uint64 resource_id1_size_; |
| 608 int64 resource_id2_; | 613 int64 resource_id2_; |
| 614 uint64 resource_id2_size_; |
| 609 scoped_refptr<ServiceWorkerRegistration> registration_; | 615 scoped_refptr<ServiceWorkerRegistration> registration_; |
| 610 }; | 616 }; |
| 611 | 617 |
| 612 class ServiceWorkerResourceStorageDiskTest | 618 class ServiceWorkerResourceStorageDiskTest |
| 613 : public ServiceWorkerResourceStorageTest { | 619 : public ServiceWorkerResourceStorageTest { |
| 614 public: | 620 public: |
| 615 virtual void SetUp() override { | 621 virtual void SetUp() override { |
| 616 ASSERT_TRUE(user_data_directory_.CreateUniqueTempDir()); | 622 ASSERT_TRUE(user_data_directory_.CreateUniqueTempDir()); |
| 617 ServiceWorkerResourceStorageTest::SetUp(); | 623 ServiceWorkerResourceStorageTest::SetUp(); |
| 618 } | 624 } |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 are_equal = true; | 1044 are_equal = true; |
| 1039 storage()->CompareScriptResources( | 1045 storage()->CompareScriptResources( |
| 1040 5, 6, | 1046 5, 6, |
| 1041 base::Bind(&OnCompareComplete, &status, &are_equal)); | 1047 base::Bind(&OnCompareComplete, &status, &are_equal)); |
| 1042 base::RunLoop().RunUntilIdle(); | 1048 base::RunLoop().RunUntilIdle(); |
| 1043 EXPECT_EQ(SERVICE_WORKER_OK, status); | 1049 EXPECT_EQ(SERVICE_WORKER_OK, status); |
| 1044 EXPECT_FALSE(are_equal); | 1050 EXPECT_FALSE(are_equal); |
| 1045 } | 1051 } |
| 1046 | 1052 |
| 1047 } // namespace content | 1053 } // namespace content |
| OLD | NEW |