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

Side by Side Diff: chrome/browser/bitmap_fetcher/bitmap_fetcher_service.cc

Issue 1763273002: base: Remove OwningMRUCache in favor of scoped_ptrs in MRUCache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + fix Created 4 years, 9 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 "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"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 ++current_request_id_; 89 ++current_request_id_;
90 int request_id = current_request_id_; 90 int request_id = current_request_id_;
91 scoped_ptr<BitmapFetcherRequest> request( 91 scoped_ptr<BitmapFetcherRequest> request(
92 new BitmapFetcherRequest(request_id, observer)); 92 new BitmapFetcherRequest(request_id, observer));
93 93
94 // Reject invalid URLs. 94 // Reject invalid URLs.
95 if (!url.is_valid()) 95 if (!url.is_valid())
96 return REQUEST_ID_INVALID; 96 return REQUEST_ID_INVALID;
97 97
98 // Check for existing images first. 98 // Check for existing images first.
99 base::OwningMRUCache<GURL, CacheEntry*>::iterator iter = cache_.Get(url); 99 auto iter = cache_.Get(url);
100 if (iter != cache_.end()) { 100 if (iter != cache_.end()) {
101 BitmapFetcherService::CacheEntry* entry = iter->second; 101 BitmapFetcherService::CacheEntry* entry = iter->second.get();
102 request->NotifyImageChanged(entry->bitmap.get()); 102 request->NotifyImageChanged(entry->bitmap.get());
103 103
104 // There is no request ID associated with this - data is already delivered. 104 // There is no request ID associated with this - data is already delivered.
105 return REQUEST_ID_INVALID; 105 return REQUEST_ID_INVALID;
106 } 106 }
107 107
108 // Limit number of simultaneous in-flight requests. 108 // Limit number of simultaneous in-flight requests.
109 if (requests_.size() > kMaxRequests) 109 if (requests_.size() > kMaxRequests)
110 return REQUEST_ID_INVALID; 110 return REQUEST_ID_INVALID;
111 111
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 while (iter != requests_.end()) { 177 while (iter != requests_.end()) {
178 if ((*iter)->get_fetcher() == fetcher) { 178 if ((*iter)->get_fetcher() == fetcher) {
179 (*iter)->NotifyImageChanged(bitmap); 179 (*iter)->NotifyImageChanged(bitmap);
180 iter = requests_.erase(iter); 180 iter = requests_.erase(iter);
181 } else { 181 } else {
182 ++iter; 182 ++iter;
183 } 183 }
184 } 184 }
185 185
186 if (bitmap && !bitmap->isNull()) { 186 if (bitmap && !bitmap->isNull()) {
187 CacheEntry* entry = new CacheEntry; 187 scoped_ptr<CacheEntry> entry(new CacheEntry);
gone 2016/03/07 22:01:32 nit: make_scoped_ptr?
danakj 2016/03/07 22:02:42 lol. I asked the opposite in the previous patch se
gone 2016/03/07 22:03:33 lol! I'm fine either way.
188 entry->bitmap.reset(new SkBitmap(*bitmap)); 188 entry->bitmap.reset(new SkBitmap(*bitmap));
189 cache_.Put(fetcher->url(), entry); 189 cache_.Put(fetcher->url(), std::move(entry));
190 } 190 }
191 191
192 RemoveFetcher(fetcher); 192 RemoveFetcher(fetcher);
193 } 193 }
OLDNEW
« no previous file with comments | « chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h ('k') | chrome/browser/ui/app_list/search/common/webservice_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698