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 #include "platform/testing/weburl_loader_mock_factory_impl.h" | 5 #include "platform/testing/weburl_loader_mock_factory_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 const WebURLResponse& response, | 59 const WebURLResponse& response, |
60 const WebURLError& error) { | 60 const WebURLError& error) { |
61 DCHECK(url_to_response_info_.find(url) == url_to_response_info_.end()); | 61 DCHECK(url_to_response_info_.find(url) == url_to_response_info_.end()); |
62 registerURL(url, response, WebString()); | 62 registerURL(url, response, WebString()); |
63 url_to_error_info_.set(url, error); | 63 url_to_error_info_.set(url, error); |
64 } | 64 } |
65 | 65 |
66 void WebURLLoaderMockFactoryImpl::unregisterURL(const blink::WebURL& url) { | 66 void WebURLLoaderMockFactoryImpl::unregisterURL(const blink::WebURL& url) { |
67 URLToResponseMap::iterator iter = url_to_response_info_.find(url); | 67 URLToResponseMap::iterator iter = url_to_response_info_.find(url); |
68 DCHECK(iter != url_to_response_info_.end()); | 68 DCHECK(iter != url_to_response_info_.end()); |
69 url_to_response_info_.remove(iter); | 69 url_to_response_info_.erase(iter); |
70 | 70 |
71 URLToErrorMap::iterator error_iter = url_to_error_info_.find(url); | 71 URLToErrorMap::iterator error_iter = url_to_error_info_.find(url); |
72 if (error_iter != url_to_error_info_.end()) | 72 if (error_iter != url_to_error_info_.end()) |
73 url_to_error_info_.remove(error_iter); | 73 url_to_error_info_.erase(error_iter); |
74 } | 74 } |
75 | 75 |
76 void WebURLLoaderMockFactoryImpl::unregisterAllURLsAndClearMemoryCache() { | 76 void WebURLLoaderMockFactoryImpl::unregisterAllURLsAndClearMemoryCache() { |
77 url_to_response_info_.clear(); | 77 url_to_response_info_.clear(); |
78 url_to_error_info_.clear(); | 78 url_to_error_info_.clear(); |
79 memoryCache()->evictResources(); | 79 memoryCache()->evictResources(); |
80 } | 80 } |
81 | 81 |
82 void WebURLLoaderMockFactoryImpl::serveAsynchronousRequests() { | 82 void WebURLLoaderMockFactoryImpl::serveAsynchronousRequests() { |
83 // Serving a request might trigger more requests, so we cannot iterate on | 83 // Serving a request might trigger more requests, so we cannot iterate on |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 177 |
178 std::string buffer; | 178 std::string buffer; |
179 if (!base::ReadFileToString(file_path, &buffer)) | 179 if (!base::ReadFileToString(file_path, &buffer)) |
180 return false; | 180 return false; |
181 | 181 |
182 data->assign(buffer.data(), buffer.size()); | 182 data->assign(buffer.data(), buffer.size()); |
183 return true; | 183 return true; |
184 } | 184 } |
185 | 185 |
186 } // namespace blink | 186 } // namespace blink |
OLD | NEW |