| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import "ios/web/public/test/http_server/html_response_provider_impl.h" | 5 #import "ios/web/public/test/http_server/html_response_provider_impl.h" |
| 6 | 6 |
| 7 #import "ios/web/public/test/http_server/response_provider.h" | 7 #import "ios/web/public/test/http_server/response_provider.h" |
| 8 #include "net/http/http_response_headers.h" | 8 #include "net/http/http_response_headers.h" |
| 9 #include "net/http/http_status_code.h" | 9 #include "net/http/http_status_code.h" |
| 10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
| 11 | 11 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 13 #error "This file requires ARC support." |
| 14 #endif |
| 15 |
| 12 namespace { | 16 namespace { |
| 13 std::map<GURL, HtmlResponseProviderImpl::Response> BuildResponseMap( | 17 std::map<GURL, HtmlResponseProviderImpl::Response> BuildResponseMap( |
| 14 const std::map<GURL, std::string>& responses_body, | 18 const std::map<GURL, std::string>& responses_body, |
| 15 scoped_refptr<net::HttpResponseHeaders> headers) { | 19 scoped_refptr<net::HttpResponseHeaders> headers) { |
| 16 std::map<GURL, HtmlResponseProviderImpl::Response> responses; | 20 std::map<GURL, HtmlResponseProviderImpl::Response> responses; |
| 17 for (const std::pair<const GURL, std::string>& pair : responses_body) { | 21 for (const std::pair<const GURL, std::string>& pair : responses_body) { |
| 18 responses.insert(std::make_pair( | 22 responses.insert(std::make_pair( |
| 19 pair.first, HtmlResponseProviderImpl::Response(pair.second, headers))); | 23 pair.first, HtmlResponseProviderImpl::Response(pair.second, headers))); |
| 20 } | 24 } |
| 21 return responses; | 25 return responses; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 95 } |
| 92 | 96 |
| 93 void HtmlResponseProviderImpl::GetResponseHeadersAndBody( | 97 void HtmlResponseProviderImpl::GetResponseHeadersAndBody( |
| 94 const web::ResponseProvider::Request& request, | 98 const web::ResponseProvider::Request& request, |
| 95 scoped_refptr<net::HttpResponseHeaders>* headers, | 99 scoped_refptr<net::HttpResponseHeaders>* headers, |
| 96 std::string* response_body) { | 100 std::string* response_body) { |
| 97 const Response& response = responses_.at(request.url); | 101 const Response& response = responses_.at(request.url); |
| 98 *headers = response.headers; | 102 *headers = response.headers; |
| 99 *response_body = response.body; | 103 *response_body = response.body; |
| 100 } | 104 } |
| OLD | NEW |