| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/image_fetcher/core/request_metadata.h" | 5 #include "components/image_fetcher/core/request_metadata.h" |
| 6 | 6 |
| 7 #include "net/http/http_response_headers.h" |
| 8 |
| 7 namespace image_fetcher { | 9 namespace image_fetcher { |
| 8 | 10 |
| 11 namespace { |
| 12 |
| 13 bool HttpHeadersEqual(const net::HttpResponseHeaders* lhs, |
| 14 const net::HttpResponseHeaders* rhs) { |
| 15 if (!lhs && !rhs) { |
| 16 return true; // Equal if both nullptr. |
| 17 } |
| 18 if (!lhs || !rhs) { |
| 19 return false; // We cannot compare the content if one of them is nullptr. |
| 20 } |
| 21 return lhs->raw_headers() == rhs->raw_headers(); |
| 22 } |
| 23 |
| 24 } // namespace |
| 25 |
| 9 RequestMetadata::RequestMetadata() | 26 RequestMetadata::RequestMetadata() |
| 10 : http_response_code(RESPONSE_CODE_INVALID), from_http_cache(false) {} | 27 : http_response_code(RESPONSE_CODE_INVALID), |
| 28 from_http_cache(false), |
| 29 http_response_headers(nullptr) {} |
| 11 | 30 |
| 12 bool operator==(const RequestMetadata& lhs, const RequestMetadata& rhs) { | 31 bool operator==(const RequestMetadata& lhs, const RequestMetadata& rhs) { |
| 13 return lhs.mime_type == rhs.mime_type && | 32 return lhs.mime_type == rhs.mime_type && |
| 14 lhs.http_response_code == rhs.http_response_code && | 33 lhs.http_response_code == rhs.http_response_code && |
| 15 lhs.from_http_cache == rhs.from_http_cache; | 34 lhs.from_http_cache == rhs.from_http_cache && |
| 35 HttpHeadersEqual(lhs.http_response_headers, rhs.http_response_headers); |
| 16 } | 36 } |
| 17 | 37 |
| 18 bool operator!=(const RequestMetadata& lhs, const RequestMetadata& rhs) { | 38 bool operator!=(const RequestMetadata& lhs, const RequestMetadata& rhs) { |
| 19 return !(lhs == rhs); | 39 return !(lhs == rhs); |
| 20 } | 40 } |
| 21 | 41 |
| 22 } // namespace image_fetcher | 42 } // namespace image_fetcher |
| OLD | NEW |