| OLD | NEW |
| 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 "platform/loader/fetch/Resource.h" | 5 #include "platform/loader/fetch/Resource.h" |
| 6 | 6 |
| 7 #include "platform/SharedBuffer.h" | 7 #include "platform/SharedBuffer.h" |
| 8 #include "platform/loader/fetch/RawResource.h" | 8 #include "platform/loader/fetch/RawResource.h" |
| 9 #include "platform/loader/fetch/ResourceRequest.h" | 9 #include "platform/loader/fetch/ResourceRequest.h" |
| 10 #include "platform/loader/fetch/ResourceResponse.h" | 10 #include "platform/loader/fetch/ResourceResponse.h" |
| 11 #include "platform/testing/TestingPlatformSupport.h" | 11 #include "platform/testing/TestingPlatformSupport.h" |
| 12 #include "platform/testing/URLTestHelpers.h" | 12 #include "platform/testing/URLTestHelpers.h" |
| 13 #include "platform/wtf/Vector.h" | 13 #include "platform/wtf/Vector.h" |
| 14 #include "public/platform/Platform.h" | 14 #include "public/platform/Platform.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 class MockPlatform final : public TestingPlatformSupportWithMockScheduler { | 21 class MockPlatform final : public TestingPlatformSupportWithMockScheduler { |
| 22 public: | 22 public: |
| 23 MockPlatform() {} | 23 MockPlatform() {} |
| 24 ~MockPlatform() override {} | 24 ~MockPlatform() override {} |
| 25 | 25 |
| 26 // From blink::Platform: | 26 // From blink::Platform: |
| 27 void CacheMetadata(const WebURL& url, int64_t, const char*, size_t) override { | 27 void CacheMetadata(const WebURL& url, int64_t, const char*, size_t) override { |
| 28 cached_ur_ls_.push_back(url); | 28 cached_urls_.push_back(url); |
| 29 } | 29 } |
| 30 | 30 |
| 31 const Vector<WebURL>& CachedURLs() const { return cached_ur_ls_; } | 31 const Vector<WebURL>& CachedURLs() const { return cached_urls_; } |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 Vector<WebURL> cached_ur_ls_; | 34 Vector<WebURL> cached_urls_; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 ResourceResponse CreateTestResourceResponse() { | 37 ResourceResponse CreateTestResourceResponse() { |
| 38 ResourceResponse response; | 38 ResourceResponse response; |
| 39 response.SetURL(URLTestHelpers::ToKURL("https://example.com/")); | 39 response.SetURL(URLTestHelpers::ToKURL("https://example.com/")); |
| 40 response.SetHTTPStatusCode(200); | 40 response.SetHTTPStatusCode(200); |
| 41 return response; | 41 return response; |
| 42 } | 42 } |
| 43 | 43 |
| 44 void CreateTestResourceAndSetCachedMetadata(const ResourceResponse& response) { | 44 void CreateTestResourceAndSetCachedMetadata(const ResourceResponse& response) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 response.SetHTTPHeaderField(HTTPNames::Vary, "User-Agent, Referer"); | 142 response.SetHTTPHeaderField(HTTPNames::Vary, "User-Agent, Referer"); |
| 143 resource->SetResponse(response); | 143 resource->SetResponse(response); |
| 144 EXPECT_TRUE(resource->MustReloadDueToVaryHeader(new_request)); | 144 EXPECT_TRUE(resource->MustReloadDueToVaryHeader(new_request)); |
| 145 | 145 |
| 146 // Two matching | 146 // Two matching |
| 147 new_request.SetHTTPHeaderField(HTTPNames::Referer, "http://foo.com"); | 147 new_request.SetHTTPHeaderField(HTTPNames::Referer, "http://foo.com"); |
| 148 EXPECT_FALSE(resource->MustReloadDueToVaryHeader(new_request)); | 148 EXPECT_FALSE(resource->MustReloadDueToVaryHeader(new_request)); |
| 149 } | 149 } |
| 150 | 150 |
| 151 } // namespace blink | 151 } // namespace blink |
| OLD | NEW |