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

Side by Side Diff: content/browser/service_worker/service_worker_job_unittest.cc

Issue 647953003: Service Worker script sizes in database. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Fixed crash where writer_ was null Created 6 years, 2 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
OLDNEW
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 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 return registration; 926 return registration;
927 } 927 }
928 928
929 // EmbeddedWorkerTestHelper overrides 929 // EmbeddedWorkerTestHelper overrides
930 virtual void OnStartWorker(int embedded_worker_id, 930 virtual void OnStartWorker(int embedded_worker_id,
931 int64 version_id, 931 int64 version_id,
932 const GURL& scope, 932 const GURL& scope,
933 const GURL& script, 933 const GURL& script,
934 bool pause_after_download) override { 934 bool pause_after_download) override {
935 const std::string kMockScriptBody = "mock_script"; 935 const std::string kMockScriptBody = "mock_script";
936 const uint64 kMockScriptSize = 19284;
936 ServiceWorkerVersion* version = context()->GetLiveVersion(version_id); 937 ServiceWorkerVersion* version = context()->GetLiveVersion(version_id);
937 ASSERT_TRUE(version); 938 ASSERT_TRUE(version);
938 version->AddListener(this); 939 version->AddListener(this);
939 940
940 if (!pause_after_download) { 941 if (!pause_after_download) {
941 // Spoof caching the script for the initial version. 942 // Spoof caching the script for the initial version.
942 int64 resource_id = storage()->NewResourceId(); 943 int64 resource_id = storage()->NewResourceId();
943 version->script_cache_map()->NotifyStartedCaching(script, resource_id); 944 version->script_cache_map()->NotifyStartedCaching(script, resource_id);
944 WriteStringResponse(storage(), resource_id, kMockScriptBody); 945 WriteStringResponse(storage(), resource_id, kMockScriptBody);
945 version->script_cache_map()->NotifyFinishedCaching( 946 version->script_cache_map()->NotifyFinishedCaching(
946 script, net::URLRequestStatus()); 947 script, kMockScriptSize, net::URLRequestStatus());
947 } else { 948 } else {
948 // Spoof caching the script for the new version. 949 // Spoof caching the script for the new version.
949 int64 resource_id = storage()->NewResourceId(); 950 int64 resource_id = storage()->NewResourceId();
950 version->script_cache_map()->NotifyStartedCaching(script, resource_id); 951 version->script_cache_map()->NotifyStartedCaching(script, resource_id);
951 if (script.GetOrigin() == kNoChangeOrigin) 952 if (script.GetOrigin() == kNoChangeOrigin)
952 WriteStringResponse(storage(), resource_id, kMockScriptBody); 953 WriteStringResponse(storage(), resource_id, kMockScriptBody);
953 else 954 else
954 WriteStringResponse(storage(), resource_id, "mock_different_script"); 955 WriteStringResponse(storage(), resource_id, "mock_different_script");
955 version->script_cache_map()->NotifyFinishedCaching( 956 version->script_cache_map()->NotifyFinishedCaching(
956 script, net::URLRequestStatus()); 957 script, kMockScriptSize, net::URLRequestStatus());
957 } 958 }
958 EmbeddedWorkerTestHelper::OnStartWorker( 959 EmbeddedWorkerTestHelper::OnStartWorker(
959 embedded_worker_id, version_id, scope, script, pause_after_download); 960 embedded_worker_id, version_id, scope, script, pause_after_download);
960 } 961 }
961 962
962 // ServiceWorkerRegistration::Listener overrides 963 // ServiceWorkerRegistration::Listener overrides
963 virtual void OnVersionAttributesChanged( 964 virtual void OnVersionAttributesChanged(
964 ServiceWorkerRegistration* registration, 965 ServiceWorkerRegistration* registration,
965 ChangedVersionAttributesMask changed_mask, 966 ChangedVersionAttributesMask changed_mask,
966 const ServiceWorkerRegistrationInfo& info) override { 967 const ServiceWorkerRegistrationInfo& info) override {
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 EXPECT_TRUE(called); 1191 EXPECT_TRUE(called);
1191 1192
1192 // Verify the registration was not modified by the Update. 1193 // Verify the registration was not modified by the Update.
1193 EXPECT_TRUE(registration->is_uninstalling()); 1194 EXPECT_TRUE(registration->is_uninstalling());
1194 EXPECT_EQ(active_version, registration->active_version()); 1195 EXPECT_EQ(active_version, registration->active_version());
1195 EXPECT_EQ(NULL, registration->waiting_version()); 1196 EXPECT_EQ(NULL, registration->waiting_version());
1196 EXPECT_EQ(NULL, registration->installing_version()); 1197 EXPECT_EQ(NULL, registration->installing_version());
1197 } 1198 }
1198 1199
1199 } // namespace content 1200 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698