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

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

Issue 2251633002: Use tri-state enum for the existence of Fetch Handler in ServiceWorkerVersion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/status/existence/ Created 4 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/browser/service_worker/service_worker_read_from_cache_job.h" 5 #include "content/browser/service_worker/service_worker_read_from_cache_job.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // Populate a registration in the storage. 90 // Populate a registration in the storage.
91 registration_ = 91 registration_ =
92 new ServiceWorkerRegistration(GURL("http://example.com/scope"), 92 new ServiceWorkerRegistration(GURL("http://example.com/scope"),
93 kRegistrationId, context()->AsWeakPtr()); 93 kRegistrationId, context()->AsWeakPtr());
94 version_ = new ServiceWorkerVersion(registration_.get(), main_script_.url, 94 version_ = new ServiceWorkerVersion(registration_.get(), main_script_.url,
95 kVersionId, context()->AsWeakPtr()); 95 kVersionId, context()->AsWeakPtr());
96 std::vector<ServiceWorkerDatabase::ResourceRecord> resources; 96 std::vector<ServiceWorkerDatabase::ResourceRecord> resources;
97 resources.push_back(main_script_); 97 resources.push_back(main_script_);
98 resources.push_back(imported_script_); 98 resources.push_back(imported_script_);
99 version_->script_cache_map()->SetResources(resources); 99 version_->script_cache_map()->SetResources(resources);
100 version_->set_fetch_handler_existence(
101 ServiceWorkerVersion::FetchHandlerExistence::EXISTS);
100 ASSERT_EQ(SERVICE_WORKER_OK, StoreRegistration()); 102 ASSERT_EQ(SERVICE_WORKER_OK, StoreRegistration());
101 ASSERT_TRUE(WriteResource(main_script_.resource_id)); 103 ASSERT_TRUE(WriteResource(main_script_.resource_id));
102 ASSERT_TRUE(WriteResource(imported_script_.resource_id)); 104 ASSERT_TRUE(WriteResource(imported_script_.resource_id));
103 } 105 }
104 106
105 bool WriteResource(int64_t resource_id) { 107 bool WriteResource(int64_t resource_id) {
106 const char kHttpHeaders[] = "HTTP/1.0 200 OK\0Content-Length: 5\0\0"; 108 const char kHttpHeaders[] = "HTTP/1.0 200 OK\0Content-Length: 5\0\0";
107 const char kHttpBody[] = "Hello"; 109 const char kHttpBody[] = "Hello";
108 const int length = arraysize(kHttpBody); 110 const int length = arraysize(kHttpBody);
109 std::string headers(kHttpHeaders, arraysize(kHttpHeaders)); 111 std::string headers(kHttpHeaders, arraysize(kHttpHeaders));
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 EXPECT_EQ(net::ERR_CACHE_MISS, request->status().error()); 243 EXPECT_EQ(net::ERR_CACHE_MISS, request->status().error());
242 EXPECT_EQ(SERVICE_WORKER_ERROR_DISK_CACHE, 244 EXPECT_EQ(SERVICE_WORKER_ERROR_DISK_CACHE,
243 DeduceStartWorkerFailureReason(SERVICE_WORKER_OK)); 245 DeduceStartWorkerFailureReason(SERVICE_WORKER_OK));
244 246
245 // The version should be doomed by the job. 247 // The version should be doomed by the job.
246 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version_->status()); 248 EXPECT_EQ(ServiceWorkerVersion::REDUNDANT, version_->status());
247 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, FindRegistration()); 249 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, FindRegistration());
248 } 250 }
249 251
250 } // namespace content 252 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698