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

Side by Side Diff: content/browser/cache_storage/cache_storage_cache_unittest.cc

Issue 1108273002: Add Client Attribute to FetchEvent- Chromium Side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 "content/browser/cache_storage/cache_storage_cache.h" 5 #include "content/browser/cache_storage/cache_storage_cache.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 210
211 void TearDown() override { 211 void TearDown() override {
212 quota_manager_proxy_->SimulateQuotaManagerDestroyed(); 212 quota_manager_proxy_->SimulateQuotaManagerDestroyed();
213 base::RunLoop().RunUntilIdle(); 213 base::RunLoop().RunUntilIdle();
214 } 214 }
215 215
216 void CreateRequests(ChromeBlobStorageContext* blob_storage_context) { 216 void CreateRequests(ChromeBlobStorageContext* blob_storage_context) {
217 ServiceWorkerHeaderMap headers; 217 ServiceWorkerHeaderMap headers;
218 headers.insert(std::make_pair("a", "a")); 218 headers.insert(std::make_pair("a", "a"));
219 headers.insert(std::make_pair("b", "b")); 219 headers.insert(std::make_pair("b", "b"));
220 body_request_ = 220 body_request_ = ServiceWorkerFetchRequest(
221 ServiceWorkerFetchRequest(GURL("http://example.com/body.html"), "GET", 221 GURL("http://example.com/body.html"), "GET", headers, Referrer(), false,
222 headers, Referrer(), false); 222 ServiceWorkerClientInfo());
223 no_body_request_ = 223 no_body_request_ = ServiceWorkerFetchRequest(
224 ServiceWorkerFetchRequest(GURL("http://example.com/no_body.html"), 224 GURL("http://example.com/no_body.html"), "GET", headers, Referrer(),
225 "GET", headers, Referrer(), false); 225 false, ServiceWorkerClientInfo());
226 226
227 std::string expected_response; 227 std::string expected_response;
228 for (int i = 0; i < 100; ++i) 228 for (int i = 0; i < 100; ++i)
229 expected_blob_data_ += kTestData; 229 expected_blob_data_ += kTestData;
230 230
231 scoped_ptr<storage::BlobDataBuilder> blob_data( 231 scoped_ptr<storage::BlobDataBuilder> blob_data(
232 new storage::BlobDataBuilder("blob-id:myblob")); 232 new storage::BlobDataBuilder("blob-id:myblob"));
233 blob_data->AppendData(expected_blob_data_); 233 blob_data->AppendData(expected_blob_data_);
234 234
235 blob_handle_ = 235 blob_handle_ =
236 blob_storage_context->context()->AddFinishedBlob(blob_data.get()); 236 blob_storage_context->context()->AddFinishedBlob(blob_data.get());
237 237
238 body_response_ = ServiceWorkerResponse( 238 body_response_ = ServiceWorkerResponse(
239 GURL("http://example.com/body.html"), 200, "OK", 239 GURL("http://example.com/body.html"), 200, "OK",
240 blink::WebServiceWorkerResponseTypeDefault, headers, 240 blink::WebServiceWorkerResponseTypeDefault, headers,
241 blob_handle_->uuid(), expected_blob_data_.size(), GURL()); 241 blob_handle_->uuid(), expected_blob_data_.size(), GURL());
242 242
243 no_body_response_ = ServiceWorkerResponse( 243 no_body_response_ = ServiceWorkerResponse(
244 GURL("http://example.com/no_body.html"), 200, "OK", 244 GURL("http://example.com/no_body.html"), 200, "OK",
245 blink::WebServiceWorkerResponseTypeDefault, headers, "", 0, GURL()); 245 blink::WebServiceWorkerResponseTypeDefault, headers, "", 0, GURL());
246 } 246 }
247 247
248 scoped_ptr<ServiceWorkerFetchRequest> CopyFetchRequest( 248 scoped_ptr<ServiceWorkerFetchRequest> CopyFetchRequest(
249 const ServiceWorkerFetchRequest& request) { 249 const ServiceWorkerFetchRequest& request) {
250 return make_scoped_ptr(new ServiceWorkerFetchRequest( 250 return make_scoped_ptr(new ServiceWorkerFetchRequest(
251 request.url, request.method, request.headers, request.referrer, 251 request.url, request.method, request.headers, request.referrer,
252 request.is_reload)); 252 request.is_reload, request.client));
253 } 253 }
254 254
255 CacheStorageError BatchOperation( 255 CacheStorageError BatchOperation(
256 const std::vector<CacheStorageBatchOperation>& operations) { 256 const std::vector<CacheStorageBatchOperation>& operations) {
257 scoped_ptr<base::RunLoop> loop(new base::RunLoop()); 257 scoped_ptr<base::RunLoop> loop(new base::RunLoop());
258 258
259 cache_->BatchOperation( 259 cache_->BatchOperation(
260 operations, 260 operations,
261 base::Bind(&CacheStorageCacheTest::ErrorTypeCallback, 261 base::Bind(&CacheStorageCacheTest::ErrorTypeCallback,
262 base::Unretained(this), base::Unretained(loop.get()))); 262 base::Unretained(this), base::Unretained(loop.get())));
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 ServiceWorkerHeaderMap(), "", 0, GURL()); 744 ServiceWorkerHeaderMap(), "", 0, GURL());
745 response.headers["content-type"] = "foo"; 745 response.headers["content-type"] = "foo";
746 response.headers["Content-Type"] = "bar"; 746 response.headers["Content-Type"] = "bar";
747 EXPECT_EQ("bar", response.headers["content-type"]); 747 EXPECT_EQ("bar", response.headers["content-type"]);
748 } 748 }
749 749
750 TEST_F(CacheStorageCacheTest, CaselessServiceWorkerFetchRequestHeaders) { 750 TEST_F(CacheStorageCacheTest, CaselessServiceWorkerFetchRequestHeaders) {
751 // CacheStorageCache depends on ServiceWorkerFetchRequest having caseless 751 // CacheStorageCache depends on ServiceWorkerFetchRequest having caseless
752 // headers so that it can quickly lookup vary headers. 752 // headers so that it can quickly lookup vary headers.
753 ServiceWorkerFetchRequest request(GURL("http://www.example.com"), "GET", 753 ServiceWorkerFetchRequest request(GURL("http://www.example.com"), "GET",
754 ServiceWorkerHeaderMap(), Referrer(), 754 ServiceWorkerHeaderMap(), Referrer(), false,
755 false); 755 ServiceWorkerClientInfo());
756 request.headers["content-type"] = "foo"; 756 request.headers["content-type"] = "foo";
757 request.headers["Content-Type"] = "bar"; 757 request.headers["Content-Type"] = "bar";
758 EXPECT_EQ("bar", request.headers["content-type"]); 758 EXPECT_EQ("bar", request.headers["content-type"]);
759 } 759 }
760 760
761 TEST_P(CacheStorageCacheTestP, QuotaManagerModified) { 761 TEST_P(CacheStorageCacheTestP, QuotaManagerModified) {
762 EXPECT_EQ(0, quota_manager_proxy_->notify_storage_modified_count()); 762 EXPECT_EQ(0, quota_manager_proxy_->notify_storage_modified_count());
763 763
764 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); 764 EXPECT_TRUE(Put(no_body_request_, no_body_response_));
765 EXPECT_EQ(1, quota_manager_proxy_->notify_storage_modified_count()); 765 EXPECT_EQ(1, quota_manager_proxy_->notify_storage_modified_count());
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 EXPECT_EQ(1, sequence_out); 862 EXPECT_EQ(1, sequence_out);
863 close_loop2->Run(); 863 close_loop2->Run();
864 EXPECT_EQ(2, sequence_out); 864 EXPECT_EQ(2, sequence_out);
865 } 865 }
866 866
867 INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest, 867 INSTANTIATE_TEST_CASE_P(CacheStorageCacheTest,
868 CacheStorageCacheTestP, 868 CacheStorageCacheTestP,
869 ::testing::Values(false, true)); 869 ::testing::Values(false, true));
870 870
871 } // namespace content 871 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/cache_storage/cache_storage_cache.cc ('k') | content/browser/cache_storage/cache_storage_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698