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

Side by Side Diff: components/image_fetcher/image_data_fetcher.cc

Issue 2693043003: Revert of Use IOSImageDataFetcherWrapper for favicon (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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 "components/image_fetcher/image_data_fetcher.h" 5 #include "components/image_fetcher/image_data_fetcher.h"
6 6
7 #include "net/base/load_flags.h" 7 #include "net/base/load_flags.h"
8 #include "net/http/http_response_headers.h" 8 #include "net/http/http_response_headers.h"
9 #include "net/http/http_status_code.h" 9 #include "net/http/http_status_code.h"
10 #include "net/url_request/url_fetcher.h" 10 #include "net/url_request/url_fetcher.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 pending_requests_[request->url_fetcher.get()] = std::move(request); 75 pending_requests_[request->url_fetcher.get()] = std::move(request);
76 } 76 }
77 77
78 void ImageDataFetcher::OnURLFetchComplete(const net::URLFetcher* source) { 78 void ImageDataFetcher::OnURLFetchComplete(const net::URLFetcher* source) {
79 auto request_iter = pending_requests_.find(source); 79 auto request_iter = pending_requests_.find(source);
80 DCHECK(request_iter != pending_requests_.end()); 80 DCHECK(request_iter != pending_requests_.end());
81 81
82 bool success = source->GetStatus().status() == net::URLRequestStatus::SUCCESS; 82 bool success = source->GetStatus().status() == net::URLRequestStatus::SUCCESS;
83 83
84 RequestMetadata metadata; 84 RequestMetadata metadata;
85 metadata.response_code = RESPONSE_CODE_INVALID;
86 if (success && source->GetResponseHeaders()) { 85 if (success && source->GetResponseHeaders()) {
87 source->GetResponseHeaders()->GetMimeType(&metadata.mime_type); 86 source->GetResponseHeaders()->GetMimeType(&metadata.mime_type);
88 metadata.response_code = source->GetResponseHeaders()->response_code(); 87 success &= (source->GetResponseHeaders()->response_code() == net::HTTP_OK);
89 success &= (metadata.response_code == net::HTTP_OK);
90 } 88 }
91 89
92 std::string image_data; 90 std::string image_data;
93 if (success) { 91 if (success) {
94 source->GetResponseAsString(&image_data); 92 source->GetResponseAsString(&image_data);
95 } 93 }
96 request_iter->second->callback.Run(image_data, metadata); 94 request_iter->second->callback.Run(image_data, metadata);
97 95
98 // Remove the finished request. 96 // Remove the finished request.
99 pending_requests_.erase(request_iter); 97 pending_requests_.erase(request_iter);
100 } 98 }
101 99
102 } // namespace image_fetcher 100 } // namespace image_fetcher
OLDNEW
« no previous file with comments | « components/image_fetcher/image_data_fetcher.h ('k') | components/image_fetcher/image_data_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698