Chromium Code Reviews| Index: content/browser/net/network_error_request_job.cc |
| diff --git a/content/browser/net/network_error_request_job.cc b/content/browser/net/network_error_request_job.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a69402514f730ed3d5d55f5525437688147bc763 |
| --- /dev/null |
| +++ b/content/browser/net/network_error_request_job.cc |
| @@ -0,0 +1,43 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/net/network_error_request_job.h" |
| + |
| +#include "base/strings/string_number_conversions.h" |
| +#include "base/values.h" |
| +#include "net/base/escape.h" |
| +#include "net/base/net_errors.h" |
| +#include "net/log/net_log_util.h" |
| +#include "net/url_request/url_request.h" |
| +#include "url/gurl.h" |
| + |
| +namespace content { |
| + |
| +NetworkErrorRequestJob::NetworkErrorRequestJob( |
| + net::URLRequest* request, |
| + net::NetworkDelegate* network_delegate) |
| + : net::URLRequestSimpleJob(request, network_delegate), |
| + error_code_(net::Error::OK) { |
| + std::basic_string<char> error_code_string = |
| + request->url().path().substr(1, std::string::npos); |
| + |
| + if (!base::StringToInt(error_code_string, &error_code_)) |
| + error_code_ = 0; |
| +} |
| + |
| +int NetworkErrorRequestJob::GetData( |
| + std::string* mime_type, |
| + std::string* charset, |
| + std::string* data, |
| + const net::CompletionCallback& callback) const { |
| + mime_type->assign("text/html"); |
| + charset->assign("UTF8"); |
| + |
| + if (error_code_ == 0 || error_code_ == net::Error::ERR_IO_PENDING) { |
| + return net::OK; |
| + } |
|
Dan Beam
2015/11/24 20:08:20
nit: no curlies
edwardjung
2015/11/24 21:42:12
Done.
|
| + return error_code_; |
| +} |
| + |
| +} // namespace content |