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

Unified Diff: content/browser/webui/url_data_manager_backend.cc

Issue 2873913002: Implement chrome://network-error with network service. (Closed)
Patch Set: merge Created 3 years, 7 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
Index: content/browser/webui/url_data_manager_backend.cc
diff --git a/content/browser/webui/url_data_manager_backend.cc b/content/browser/webui/url_data_manager_backend.cc
index fabcd986bc219db44f81584173c14da0a8a36ef2..495f3fe689e649acbbda1ed642d1b9c36a58816b 100644
--- a/content/browser/webui/url_data_manager_backend.cc
+++ b/content/browser/webui/url_data_manager_backend.cc
@@ -348,30 +348,6 @@ void URLRequestChromeJob::StartAsync() {
namespace {
-bool IsValidNetworkErrorCode(int error_code) {
- std::unique_ptr<base::DictionaryValue> error_codes = net::GetNetConstants();
- const base::DictionaryValue* net_error_codes_dict = nullptr;
-
- for (base::DictionaryValue::Iterator itr(*error_codes); !itr.IsAtEnd();
- itr.Advance()) {
- if (itr.key() == kNetworkErrorKey) {
- itr.value().GetAsDictionary(&net_error_codes_dict);
- break;
- }
- }
-
- if (net_error_codes_dict != nullptr) {
- for (base::DictionaryValue::Iterator itr(*net_error_codes_dict);
- !itr.IsAtEnd(); itr.Advance()) {
- int net_error_code;
- itr.value().GetAsInteger(&net_error_code);
- if (error_code == net_error_code)
- return true;
- }
- }
- return false;
-}
-
class ChromeProtocolHandler
: public net::URLRequestJobFactory::ProtocolHandler {
public:
@@ -413,7 +389,7 @@ class ChromeProtocolHandler
int error_code;
if (base::StringToInt(error_code_string, &error_code)) {
// Check for a valid error code.
- if (IsValidNetworkErrorCode(error_code) &&
+ if (URLDataManagerBackend::IsValidNetworkErrorCode(error_code) &&
error_code != net::Error::ERR_IO_PENDING) {
return new net::URLRequestErrorJob(request, network_delegate,
error_code);
@@ -701,6 +677,30 @@ void URLDataManagerBackend::URLToRequestPath(const GURL& url,
path->assign(spec.substr(offset));
}
+bool URLDataManagerBackend::IsValidNetworkErrorCode(int error_code) {
+ std::unique_ptr<base::DictionaryValue> error_codes = net::GetNetConstants();
+ const base::DictionaryValue* net_error_codes_dict = nullptr;
+
+ for (base::DictionaryValue::Iterator itr(*error_codes); !itr.IsAtEnd();
+ itr.Advance()) {
+ if (itr.key() == kNetworkErrorKey) {
+ itr.value().GetAsDictionary(&net_error_codes_dict);
+ break;
+ }
+ }
+
+ if (net_error_codes_dict != nullptr) {
+ for (base::DictionaryValue::Iterator itr(*net_error_codes_dict);
+ !itr.IsAtEnd(); itr.Advance()) {
+ int net_error_code;
+ itr.value().GetAsInteger(&net_error_code);
+ if (error_code == net_error_code)
+ return true;
+ }
+ }
+ return false;
+}
+
std::vector<std::string> URLDataManagerBackend::GetWebUISchemes() {
std::vector<std::string> schemes;
schemes.push_back(kChromeUIScheme);
« no previous file with comments | « content/browser/webui/url_data_manager_backend.h ('k') | content/browser/webui/web_ui_url_loader_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698