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 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h" | 5 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" | 12 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "content/public/browser/storage_partition.h" |
14 #include "net/base/load_flags.h" | 15 #include "net/base/load_flags.h" |
15 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 const size_t kMaxRequests = 25; // Maximum number of inflight requests allowed. | 20 const size_t kMaxRequests = 25; // Maximum number of inflight requests allowed. |
20 const int kMaxCacheEntries = 5; // Maximum number of cache entries. | 21 const int kMaxCacheEntries = 5; // Maximum number of cache entries. |
21 | 22 |
22 } // namespace. | 23 } // namespace. |
23 | 24 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 if (url.is_valid()) | 122 if (url.is_valid()) |
122 EnsureFetcherForUrl(url); | 123 EnsureFetcherForUrl(url); |
123 } | 124 } |
124 | 125 |
125 scoped_ptr<chrome::BitmapFetcher> BitmapFetcherService::CreateFetcher( | 126 scoped_ptr<chrome::BitmapFetcher> BitmapFetcherService::CreateFetcher( |
126 const GURL& url) { | 127 const GURL& url) { |
127 scoped_ptr<chrome::BitmapFetcher> new_fetcher( | 128 scoped_ptr<chrome::BitmapFetcher> new_fetcher( |
128 new chrome::BitmapFetcher(url, this)); | 129 new chrome::BitmapFetcher(url, this)); |
129 | 130 |
130 new_fetcher->Init( | 131 new_fetcher->Init( |
131 context_->GetRequestContext(), | 132 content::BrowserContext::GetDefaultStoragePartition(context_)-> |
| 133 GetURLRequestContext(), |
132 std::string(), | 134 std::string(), |
133 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, | 135 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, |
134 net::LOAD_NORMAL); | 136 net::LOAD_NORMAL); |
135 new_fetcher->Start(); | 137 new_fetcher->Start(); |
136 return new_fetcher; | 138 return new_fetcher; |
137 } | 139 } |
138 | 140 |
139 const chrome::BitmapFetcher* BitmapFetcherService::EnsureFetcherForUrl( | 141 const chrome::BitmapFetcher* BitmapFetcherService::EnsureFetcherForUrl( |
140 const GURL& url) { | 142 const GURL& url) { |
141 const chrome::BitmapFetcher* fetcher = FindFetcherForUrl(url); | 143 const chrome::BitmapFetcher* fetcher = FindFetcherForUrl(url); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 186 } |
185 | 187 |
186 if (bitmap && !bitmap->isNull()) { | 188 if (bitmap && !bitmap->isNull()) { |
187 scoped_ptr<CacheEntry> entry(new CacheEntry); | 189 scoped_ptr<CacheEntry> entry(new CacheEntry); |
188 entry->bitmap.reset(new SkBitmap(*bitmap)); | 190 entry->bitmap.reset(new SkBitmap(*bitmap)); |
189 cache_.Put(fetcher->url(), std::move(entry)); | 191 cache_.Put(fetcher->url(), std::move(entry)); |
190 } | 192 } |
191 | 193 |
192 RemoveFetcher(fetcher); | 194 RemoveFetcher(fetcher); |
193 } | 195 } |
OLD | NEW |