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

Unified Diff: content/child/ftp_directory_listing_response_delegate.cc

Issue 2823173003: Improve error handling in FtpDirectoryListingResponseDelegate. (Closed)
Patch Set: Created 3 years, 8 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 | « content/child/ftp_directory_listing_response_delegate.h ('k') | content/child/web_url_loader_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/ftp_directory_listing_response_delegate.cc
diff --git a/content/child/ftp_directory_listing_response_delegate.cc b/content/child/ftp_directory_listing_response_delegate.cc
index 5b7763eed636054b53738afbc2e7068478fbe72f..554e2faafc2240fbf9cbe065c8a0ca0d54d15471 100644
--- a/content/child/ftp_directory_listing_response_delegate.cc
+++ b/content/child/ftp_directory_listing_response_delegate.cc
@@ -23,11 +23,9 @@
#include "net/ftp/ftp_directory_listing_parser.h"
#include "net/net_features.h"
#include "third_party/WebKit/public/platform/WebURL.h"
+#include "third_party/WebKit/public/platform/WebURLLoader.h"
#include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
-using blink::WebURLLoader;
-using blink::WebURLLoaderClient;
-using blink::WebURLResponse;
using net::FtpDirectoryListingEntry;
namespace {
@@ -59,11 +57,10 @@ base::string16 ConvertPathToUTF16(const std::string& path) {
namespace content {
FtpDirectoryListingResponseDelegate::FtpDirectoryListingResponseDelegate(
- WebURLLoaderClient* client,
- WebURLLoader* loader,
- const WebURLResponse& response)
- : client_(client),
- loader_(loader) {
+ blink::WebURLLoaderClient* client,
+ blink::WebURLLoader* loader,
+ const blink::WebURLResponse& response)
+ : client_(client), loader_(loader) {
if (response.GetExtraData()) {
// |extra_data| can be NULL during tests.
WebURLResponseExtraDataImpl* extra_data =
@@ -83,14 +80,20 @@ void FtpDirectoryListingResponseDelegate::OnReceivedData(const char* data,
buffer_.append(data, data_len);
}
-void FtpDirectoryListingResponseDelegate::OnCompletedRequest() {
+void FtpDirectoryListingResponseDelegate::OnCompletedRequest(int error_code) {
std::vector<FtpDirectoryListingEntry> entries;
int rv = net::ERR_NOT_IMPLEMENTED;
#if !BUILDFLAG(DISABLE_FTP_SUPPORT)
- rv = net::ParseFtpDirectoryListing(buffer_, base::Time::Now(), &entries);
+ if (error_code == net::OK)
+ rv = net::ParseFtpDirectoryListing(buffer_, base::Time::Now(), &entries);
+ else
+ rv = error_code;
#endif
+ buffer_.clear();
if (rv != net::OK) {
SendDataToClient("<script>onListingParsingError();</script>\n");
+ if (loader_)
+ loader_->Cancel();
return;
}
for (const FtpDirectoryListingEntry& entry : entries) {
@@ -125,7 +128,7 @@ void FtpDirectoryListingResponseDelegate::Init(const GURL& response_url) {
}
void FtpDirectoryListingResponseDelegate::SendDataToClient(
- const std::string& data) {
+ base::StringPiece data) {
if (client_) {
client_->DidReceiveData(data.data(), data.length());
}
« no previous file with comments | « content/child/ftp_directory_listing_response_delegate.h ('k') | content/child/web_url_loader_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698