| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/blink/cache_util.h" | 5 #include "media/blink/cache_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 struct GRFUTestCase { | 28 struct GRFUTestCase { |
| 29 WebURLResponse::HTTPVersion version; | 29 WebURLResponse::HTTPVersion version; |
| 30 int status_code; | 30 int status_code; |
| 31 const char* headers; | 31 const char* headers; |
| 32 uint32_t expected_reasons; | 32 uint32_t expected_reasons; |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 // Create a new WebURLResponse object. | 35 // Create a new WebURLResponse object. |
| 36 static WebURLResponse CreateResponse(const GRFUTestCase& test) { | 36 static WebURLResponse CreateResponse(const GRFUTestCase& test) { |
| 37 WebURLResponse response; | 37 WebURLResponse response; |
| 38 response.initialize(); | |
| 39 response.setHTTPVersion(test.version); | 38 response.setHTTPVersion(test.version); |
| 40 response.setHTTPStatusCode(test.status_code); | 39 response.setHTTPStatusCode(test.status_code); |
| 41 for (const std::string& line : | 40 for (const std::string& line : |
| 42 base::SplitString(test.headers, "\n", base::KEEP_WHITESPACE, | 41 base::SplitString(test.headers, "\n", base::KEEP_WHITESPACE, |
| 43 base::SPLIT_WANT_NONEMPTY)) { | 42 base::SPLIT_WANT_NONEMPTY)) { |
| 44 size_t colon = line.find(": "); | 43 size_t colon = line.find(": "); |
| 45 response.addHTTPHeaderField( | 44 response.addHTTPHeaderField( |
| 46 WebString::fromUTF8(line.substr(0, colon)), | 45 WebString::fromUTF8(line.substr(0, colon)), |
| 47 WebString::fromUTF8(line.substr(colon + 2))); | 46 WebString::fromUTF8(line.substr(colon + 2))); |
| 48 } | 47 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 79 SCOPED_TRACE(base::StringPrintf("case: %" PRIuS | 78 SCOPED_TRACE(base::StringPrintf("case: %" PRIuS |
| 80 ", version: %d, code: %d, headers: %s", | 79 ", version: %d, code: %d, headers: %s", |
| 81 i, tests[i].version, tests[i].status_code, | 80 i, tests[i].version, tests[i].status_code, |
| 82 tests[i].headers)); | 81 tests[i].headers)); |
| 83 EXPECT_EQ(GetReasonsForUncacheability(CreateResponse(tests[i])), | 82 EXPECT_EQ(GetReasonsForUncacheability(CreateResponse(tests[i])), |
| 84 tests[i].expected_reasons); | 83 tests[i].expected_reasons); |
| 85 } | 84 } |
| 86 } | 85 } |
| 87 | 86 |
| 88 } // namespace media | 87 } // namespace media |
| OLD | NEW |