OLD | NEW |
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 <stdint.h> | 5 #include <stdint.h> |
6 #include <tuple> | 6 #include <tuple> |
7 | 7 |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 kServiceWorkerScriptMaxCacheAgeInHours)) { | 852 kServiceWorkerScriptMaxCacheAgeInHours)) { |
853 version->embedded_worker()->OnNetworkAccessedForScriptLoad(); | 853 version->embedded_worker()->OnNetworkAccessedForScriptLoad(); |
854 } | 854 } |
855 | 855 |
856 int64_t resource_id = storage()->NewResourceId(); | 856 int64_t resource_id = storage()->NewResourceId(); |
857 version->script_cache_map()->NotifyStartedCaching(script, resource_id); | 857 version->script_cache_map()->NotifyStartedCaching(script, resource_id); |
858 if (!is_update) { | 858 if (!is_update) { |
859 // Spoof caching the script for the initial version. | 859 // Spoof caching the script for the initial version. |
860 WriteStringResponse(storage(), resource_id, kMockScriptBody); | 860 WriteStringResponse(storage(), resource_id, kMockScriptBody); |
861 version->script_cache_map()->NotifyFinishedCaching( | 861 version->script_cache_map()->NotifyFinishedCaching( |
862 script, kMockScriptSize, net::URLRequestStatus(), std::string()); | 862 script, kMockScriptSize, net::OK, std::string()); |
863 } else { | 863 } else { |
864 if (script.GetOrigin() == kNoChangeOrigin) { | 864 if (script.GetOrigin() == kNoChangeOrigin) { |
865 // Simulate fetching the updated script and finding it's identical to | 865 // Simulate fetching the updated script and finding it's identical to |
866 // the incumbent. | 866 // the incumbent. |
867 net::URLRequestStatus status = | |
868 net::URLRequestStatus::FromError(net::ERR_FILE_EXISTS); | |
869 version->script_cache_map()->NotifyFinishedCaching( | 867 version->script_cache_map()->NotifyFinishedCaching( |
870 script, kMockScriptSize, status, std::string()); | 868 script, kMockScriptSize, net::ERR_FILE_EXISTS, std::string()); |
871 SimulateWorkerScriptLoaded(embedded_worker_id); | 869 SimulateWorkerScriptLoaded(embedded_worker_id); |
872 return; | 870 return; |
873 } | 871 } |
874 | 872 |
875 // Spoof caching the script for the new version. | 873 // Spoof caching the script for the new version. |
876 WriteStringResponse(storage(), resource_id, "mock_different_script"); | 874 WriteStringResponse(storage(), resource_id, "mock_different_script"); |
877 version->script_cache_map()->NotifyFinishedCaching( | 875 version->script_cache_map()->NotifyFinishedCaching( |
878 script, kMockScriptSize, net::URLRequestStatus(), std::string()); | 876 script, kMockScriptSize, net::OK, std::string()); |
879 } | 877 } |
880 | 878 |
881 EmbeddedWorkerTestHelper::OnStartWorker( | 879 EmbeddedWorkerTestHelper::OnStartWorker( |
882 embedded_worker_id, version_id, scope, script, pause_after_download); | 880 embedded_worker_id, version_id, scope, script, pause_after_download); |
883 } | 881 } |
884 | 882 |
885 void OnResumeAfterDownload(int embedded_worker_id) override { | 883 void OnResumeAfterDownload(int embedded_worker_id) override { |
886 if (!force_start_worker_failure_) { | 884 if (!force_start_worker_failure_) { |
887 EmbeddedWorkerTestHelper::OnResumeAfterDownload(embedded_worker_id); | 885 EmbeddedWorkerTestHelper::OnResumeAfterDownload(embedded_worker_id); |
888 } else { | 886 } else { |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1694 // should not be promoted to ACTIVATED because failure occur | 1692 // should not be promoted to ACTIVATED because failure occur |
1695 // during shutdown. | 1693 // during shutdown. |
1696 runner->RunUntilIdle(); | 1694 runner->RunUntilIdle(); |
1697 base::RunLoop().RunUntilIdle(); | 1695 base::RunLoop().RunUntilIdle(); |
1698 EXPECT_EQ(new_version.get(), registration->active_version()); | 1696 EXPECT_EQ(new_version.get(), registration->active_version()); |
1699 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); | 1697 EXPECT_EQ(ServiceWorkerVersion::ACTIVATING, new_version->status()); |
1700 registration->RemoveListener(update_helper); | 1698 registration->RemoveListener(update_helper); |
1701 } | 1699 } |
1702 | 1700 |
1703 } // namespace content | 1701 } // namespace content |
OLD | NEW |