Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Unified Diff: webkit/support/weburl_loader_mock_factory.cc

Issue 10821019: Add support for mocking failed loads to WebURLLoaderMock. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/support/weburl_loader_mock_factory.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/support/weburl_loader_mock_factory.cc
===================================================================
--- webkit/support/weburl_loader_mock_factory.cc (revision 148351)
+++ webkit/support/weburl_loader_mock_factory.cc (working copy)
@@ -50,14 +50,28 @@
url_to_reponse_info_[url] = response_info;
}
+
+void WebURLLoaderMockFactory::RegisterErrorURL(const WebURL& url,
+ const WebURLResponse& response,
+ const WebURLError& error) {
+ DCHECK(url_to_reponse_info_.find(url) == url_to_reponse_info_.end());
+ RegisterURL(url, response, WebString());
+ url_to_error_info_[url] = error;
+}
+
void WebURLLoaderMockFactory::UnregisterURL(const WebKit::WebURL& url) {
URLToResponseMap::iterator iter = url_to_reponse_info_.find(url);
DCHECK(iter != url_to_reponse_info_.end());
url_to_reponse_info_.erase(iter);
+
+ URLToErrorMap::iterator error_iter = url_to_error_info_.find(url);
+ if (error_iter != url_to_error_info_.end())
+ url_to_error_info_.erase(error_iter);
}
void WebURLLoaderMockFactory::UnregisterAllURLs() {
url_to_reponse_info_.clear();
+ url_to_error_info_.clear();
}
void WebURLLoaderMockFactory::ServeAsynchronousRequests() {
@@ -129,6 +143,11 @@
WebURLResponse* response,
WebURLError* error,
WebData* data) {
+ URLToErrorMap::const_iterator error_iter =
+ url_to_error_info_.find(request.url());
+ if (error_iter != url_to_error_info_.end())
+ *error = error_iter->second;
+
URLToResponseMap::const_iterator iter =
url_to_reponse_info_.find(request.url());
if (iter == url_to_reponse_info_.end()) {
@@ -137,7 +156,7 @@
return;
}
- if (!ReadFile(iter->second.file_path, data)) {
+ if (!error->reason && !ReadFile(iter->second.file_path, data)) {
NOTREACHED();
return;
}
« no previous file with comments | « webkit/support/weburl_loader_mock_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698