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

Side by Side Diff: components/image_fetcher/core/image_fetcher_impl.cc

Issue 2794343002: Network traffic annotation added to image_data_fetcher. (Closed)
Patch Set: Annotation updated. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/core/image_fetcher_impl.h" 5 #include "components/image_fetcher/core/image_fetcher_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "net/base/load_flags.h" 10 #include "net/base/load_flags.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 45
46 void ImageFetcherImpl::SetImageDownloadLimit( 46 void ImageFetcherImpl::SetImageDownloadLimit(
47 base::Optional<int64_t> max_download_bytes) { 47 base::Optional<int64_t> max_download_bytes) {
48 image_data_fetcher_->SetImageDownloadLimit(max_download_bytes); 48 image_data_fetcher_->SetImageDownloadLimit(max_download_bytes);
49 } 49 }
50 50
51 void ImageFetcherImpl::StartOrQueueNetworkRequest( 51 void ImageFetcherImpl::StartOrQueueNetworkRequest(
52 const std::string& id, 52 const std::string& id,
53 const GURL& image_url, 53 const GURL& image_url,
54 const ImageFetcherCallback& callback) { 54 const ImageFetcherCallback& callback,
55 const net::NetworkTrafficAnnotationTag& traffic_annotation) {
55 // Before starting to fetch the image. Look for a request in progress for 56 // Before starting to fetch the image. Look for a request in progress for
56 // |image_url|, and queue if appropriate. 57 // |image_url|, and queue if appropriate.
57 ImageRequestMap::iterator it = pending_net_requests_.find(image_url); 58 ImageRequestMap::iterator it = pending_net_requests_.find(image_url);
58 if (it == pending_net_requests_.end()) { 59 if (it == pending_net_requests_.end()) {
59 ImageRequest request; 60 ImageRequest request;
60 request.id = id; 61 request.id = id;
61 request.callbacks.push_back(callback); 62 request.callbacks.push_back(callback);
62 pending_net_requests_[image_url].swap(&request); 63 pending_net_requests_[image_url].swap(&request);
63 64
64 image_data_fetcher_->FetchImageData( 65 image_data_fetcher_->FetchImageData(
65 image_url, base::Bind(&ImageFetcherImpl::OnImageURLFetched, 66 image_url,
66 base::Unretained(this), image_url)); 67 base::Bind(&ImageFetcherImpl::OnImageURLFetched, base::Unretained(this),
68 image_url),
69 traffic_annotation);
67 } else { 70 } else {
68 // Request in progress. Register as an interested callback. 71 // Request in progress. Register as an interested callback.
69 // TODO(treib,markusheintz): We're not guaranteed that the ID also matches. 72 // TODO(treib,markusheintz): We're not guaranteed that the ID also matches.
70 // We probably have to store them all. 73 // We probably have to store them all.
71 it->second.callbacks.push_back(callback); 74 it->second.callbacks.push_back(callback);
72 } 75 }
73 } 76 }
74 77
75 void ImageFetcherImpl::OnImageURLFetched(const GURL& image_url, 78 void ImageFetcherImpl::OnImageURLFetched(const GURL& image_url,
76 const std::string& image_data, 79 const std::string& image_data,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 111
109 // Erase the completed ImageRequest. 112 // Erase the completed ImageRequest.
110 pending_net_requests_.erase(image_iter); 113 pending_net_requests_.erase(image_iter);
111 } 114 }
112 115
113 ImageDecoder* ImageFetcherImpl::GetImageDecoder() { 116 ImageDecoder* ImageFetcherImpl::GetImageDecoder() {
114 return image_decoder_.get(); 117 return image_decoder_.get();
115 } 118 }
116 119
117 } // namespace image_fetcher 120 } // namespace image_fetcher
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698