OLD | NEW |
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 // This class holds the URL to an image and the bitmap for the fetched image, | 5 // This class holds the URL to an image and the bitmap for the fetched image, |
6 // and has code to fetch the bitmap from the URL. | 6 // and has code to fetch the bitmap from the URL. |
7 | 7 |
8 #include "chrome/browser/image_holder.h" | 8 #include "chrome/browser/image_holder.h" |
9 | 9 |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "net/base/load_flags.h" | 11 #include "net/base/load_flags.h" |
| 12 #include "net/traffic_annotation/network_traffic_annotation.h" |
12 | 13 |
13 namespace chrome { | 14 namespace chrome { |
14 | 15 |
15 ImageHolder::ImageHolder(const GURL& low_dpi_url, | 16 ImageHolder::ImageHolder(const GURL& low_dpi_url, |
16 const GURL& high_dpi_url, | 17 const GURL& high_dpi_url, |
17 Profile* profile, | 18 Profile* profile, |
18 ImageHolderDelegate* delegate) | 19 ImageHolderDelegate* delegate) |
19 : low_dpi_url_(low_dpi_url), | 20 : low_dpi_url_(low_dpi_url), |
20 high_dpi_url_(high_dpi_url), | 21 high_dpi_url_(high_dpi_url), |
21 low_dpi_fetched_(false), | 22 low_dpi_fetched_(false), |
(...skipping 30 matching lines...) Expand all Loading... |
52 // If this bitmap has a valid GURL, create a fetcher for it. | 53 // If this bitmap has a valid GURL, create a fetcher for it. |
53 void ImageHolder::CreateBitmapFetcher(const GURL& url) { | 54 void ImageHolder::CreateBitmapFetcher(const GURL& url) { |
54 // Check for dups, ignore any request for a dup. | 55 // Check for dups, ignore any request for a dup. |
55 ScopedVector<chrome::BitmapFetcher>::iterator iter; | 56 ScopedVector<chrome::BitmapFetcher>::iterator iter; |
56 for (iter = fetchers_.begin(); iter != fetchers_.end(); ++iter) { | 57 for (iter = fetchers_.begin(); iter != fetchers_.end(); ++iter) { |
57 if ((*iter)->url() == url) | 58 if ((*iter)->url() == url) |
58 return; | 59 return; |
59 } | 60 } |
60 | 61 |
61 if (url.is_valid()) { | 62 if (url.is_valid()) { |
62 fetchers_.push_back(new chrome::BitmapFetcher(url, this)); | 63 net::NetworkTrafficAnnotationTag traffic_annotation = |
| 64 net::DefineNetworkTrafficAnnotation("", R"( |
| 65 semantics { |
| 66 sender: "" |
| 67 description: "" |
| 68 trigger: "" |
| 69 data: "" |
| 70 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER |
| 71 } |
| 72 policy { |
| 73 cookies_allowed: false/true |
| 74 cookies_store_exceptions: "" |
| 75 setting: "" |
| 76 policy { |
| 77 [POLICY_NAME] { |
| 78 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} |
| 79 value: ... |
| 80 } |
| 81 } |
| 82 })"); |
| 83 fetchers_.push_back( |
| 84 new chrome::BitmapFetcher(url, this, traffic_annotation)); |
63 DVLOG(2) << __func__ << "Pushing bitmap " << url; | 85 DVLOG(2) << __func__ << "Pushing bitmap " << url; |
64 } | 86 } |
65 } | 87 } |
66 | 88 |
67 void ImageHolder::StartFetch() { | 89 void ImageHolder::StartFetch() { |
68 // Now that we have queued them all, start the fetching. | 90 // Now that we have queued them all, start the fetching. |
69 ScopedVector<chrome::BitmapFetcher>::iterator iter; | 91 ScopedVector<chrome::BitmapFetcher>::iterator iter; |
70 for (iter = fetchers_.begin(); iter != fetchers_.end(); ++iter) { | 92 for (iter = fetchers_.begin(); iter != fetchers_.end(); ++iter) { |
71 (*iter)->Init( | 93 (*iter)->Init( |
72 profile_->GetRequestContext(), | 94 profile_->GetRequestContext(), |
(...skipping 19 matching lines...) Expand all Loading... |
92 image_.AddRepresentation(gfx::ImageSkiaRep(*bitmap, 2.0)); | 114 image_.AddRepresentation(gfx::ImageSkiaRep(*bitmap, 2.0)); |
93 } else { | 115 } else { |
94 DVLOG(2) << __func__ << "Unmatched bitmap arrived " << url; | 116 DVLOG(2) << __func__ << "Unmatched bitmap arrived " << url; |
95 } | 117 } |
96 | 118 |
97 // Notify callback of bitmap arrival. | 119 // Notify callback of bitmap arrival. |
98 delegate_->OnFetchComplete(); | 120 delegate_->OnFetchComplete(); |
99 } | 121 } |
100 | 122 |
101 } // namespace chrome. | 123 } // namespace chrome. |
OLD | NEW |