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

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

Issue 2677993002: Use IOSImageDataFetcherWrapper for favicon (Closed)
Patch Set: Actually adding the header 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;
85 if (success && source->GetResponseHeaders()) { 86 if (success && source->GetResponseHeaders()) {
86 source->GetResponseHeaders()->GetMimeType(&metadata.mime_type); 87 source->GetResponseHeaders()->GetMimeType(&metadata.mime_type);
87 success &= (source->GetResponseHeaders()->response_code() == net::HTTP_OK); 88 metadata.response_code = source->GetResponseHeaders()->response_code();
89 success &= (metadata.response_code == net::HTTP_OK);
88 } 90 }
89 91
90 std::string image_data; 92 std::string image_data;
91 if (success) { 93 if (success) {
92 source->GetResponseAsString(&image_data); 94 source->GetResponseAsString(&image_data);
93 } 95 }
94 request_iter->second->callback.Run(image_data, metadata); 96 request_iter->second->callback.Run(image_data, metadata);
95 97
96 // Remove the finished request. 98 // Remove the finished request.
97 pending_requests_.erase(request_iter); 99 pending_requests_.erase(request_iter);
98 } 100 }
99 101
100 } // namespace image_fetcher 102 } // 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