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 "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 20 matching lines...) Expand all Loading... |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 int kMockRenderProcessId = 88; | 34 int kMockRenderProcessId = 88; |
35 | 35 |
36 void SaveRegistrationCallback( | 36 void SaveRegistrationCallback( |
37 ServiceWorkerStatusCode expected_status, | 37 ServiceWorkerStatusCode expected_status, |
38 bool* called, | 38 bool* called, |
39 scoped_refptr<ServiceWorkerRegistration>* registration_out, | 39 scoped_refptr<ServiceWorkerRegistration>* registration_out, |
40 ServiceWorkerStatusCode status, | 40 ServiceWorkerStatusCode status, |
| 41 const std::string& status_message, |
41 ServiceWorkerRegistration* registration) { | 42 ServiceWorkerRegistration* registration) { |
42 EXPECT_EQ(expected_status, status); | 43 EXPECT_EQ(expected_status, status); |
43 *called = true; | 44 *called = true; |
44 *registration_out = registration; | 45 *registration_out = registration; |
45 } | 46 } |
46 | 47 |
47 void SaveFoundRegistrationCallback( | 48 void SaveFoundRegistrationCallback( |
48 ServiceWorkerStatusCode expected_status, | 49 ServiceWorkerStatusCode expected_status, |
49 bool* called, | 50 bool* called, |
50 scoped_refptr<ServiceWorkerRegistration>* registration, | 51 scoped_refptr<ServiceWorkerRegistration>* registration, |
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 ServiceWorkerVersion* version = context()->GetLiveVersion(version_id); | 938 ServiceWorkerVersion* version = context()->GetLiveVersion(version_id); |
938 ASSERT_TRUE(version); | 939 ASSERT_TRUE(version); |
939 version->AddListener(this); | 940 version->AddListener(this); |
940 | 941 |
941 if (!pause_after_download) { | 942 if (!pause_after_download) { |
942 // Spoof caching the script for the initial version. | 943 // Spoof caching the script for the initial version. |
943 int64 resource_id = storage()->NewResourceId(); | 944 int64 resource_id = storage()->NewResourceId(); |
944 version->script_cache_map()->NotifyStartedCaching(script, resource_id); | 945 version->script_cache_map()->NotifyStartedCaching(script, resource_id); |
945 WriteStringResponse(storage(), resource_id, kMockScriptBody); | 946 WriteStringResponse(storage(), resource_id, kMockScriptBody); |
946 version->script_cache_map()->NotifyFinishedCaching( | 947 version->script_cache_map()->NotifyFinishedCaching( |
947 script, kMockScriptSize, net::URLRequestStatus()); | 948 script, kMockScriptSize, net::URLRequestStatus(), std::string()); |
948 } else { | 949 } else { |
949 // Spoof caching the script for the new version. | 950 // Spoof caching the script for the new version. |
950 int64 resource_id = storage()->NewResourceId(); | 951 int64 resource_id = storage()->NewResourceId(); |
951 version->script_cache_map()->NotifyStartedCaching(script, resource_id); | 952 version->script_cache_map()->NotifyStartedCaching(script, resource_id); |
952 if (script.GetOrigin() == kNoChangeOrigin) | 953 if (script.GetOrigin() == kNoChangeOrigin) |
953 WriteStringResponse(storage(), resource_id, kMockScriptBody); | 954 WriteStringResponse(storage(), resource_id, kMockScriptBody); |
954 else | 955 else |
955 WriteStringResponse(storage(), resource_id, "mock_different_script"); | 956 WriteStringResponse(storage(), resource_id, "mock_different_script"); |
956 version->script_cache_map()->NotifyFinishedCaching( | 957 version->script_cache_map()->NotifyFinishedCaching( |
957 script, kMockScriptSize, net::URLRequestStatus()); | 958 script, kMockScriptSize, net::URLRequestStatus(), std::string()); |
958 } | 959 } |
959 EmbeddedWorkerTestHelper::OnStartWorker( | 960 EmbeddedWorkerTestHelper::OnStartWorker( |
960 embedded_worker_id, version_id, scope, script, pause_after_download); | 961 embedded_worker_id, version_id, scope, script, pause_after_download); |
961 } | 962 } |
962 | 963 |
963 // ServiceWorkerRegistration::Listener overrides | 964 // ServiceWorkerRegistration::Listener overrides |
964 void OnVersionAttributesChanged( | 965 void OnVersionAttributesChanged( |
965 ServiceWorkerRegistration* registration, | 966 ServiceWorkerRegistration* registration, |
966 ChangedVersionAttributesMask changed_mask, | 967 ChangedVersionAttributesMask changed_mask, |
967 const ServiceWorkerRegistrationInfo& info) override { | 968 const ServiceWorkerRegistrationInfo& info) override { |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1199 EXPECT_TRUE(called); | 1200 EXPECT_TRUE(called); |
1200 | 1201 |
1201 // Verify the registration was not modified by the Update. | 1202 // Verify the registration was not modified by the Update. |
1202 EXPECT_TRUE(registration->is_uninstalling()); | 1203 EXPECT_TRUE(registration->is_uninstalling()); |
1203 EXPECT_EQ(active_version, registration->active_version()); | 1204 EXPECT_EQ(active_version, registration->active_version()); |
1204 EXPECT_EQ(NULL, registration->waiting_version()); | 1205 EXPECT_EQ(NULL, registration->waiting_version()); |
1205 EXPECT_EQ(NULL, registration->installing_version()); | 1206 EXPECT_EQ(NULL, registration->installing_version()); |
1206 } | 1207 } |
1207 | 1208 |
1208 } // namespace content | 1209 } // namespace content |
OLD | NEW |