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

Unified Diff: content/renderer/image_downloader/image_downloader_base.cc

Issue 2705073003: Remove ScopedVector from content/renderer/. (Closed)
Patch Set: Rebase only 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/image_downloader/image_downloader_base.cc
diff --git a/content/renderer/image_downloader/image_downloader_base.cc b/content/renderer/image_downloader/image_downloader_base.cc
index fffdeb3e724cb1591ebe08126399da537f2bc8dc..9814b389985d97934c50e9fa24bd03967afd66f3 100644
--- a/content/renderer/image_downloader/image_downloader_base.cc
+++ b/content/renderer/image_downloader/image_downloader_base.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
#include "content/child/image_decoder.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_thread.h"
@@ -93,13 +94,15 @@ bool ImageDownloaderBase::FetchImage(const GURL& image_url,
DCHECK(frame);
// Create an image resource fetcher and assign it with a call back object.
- image_fetchers_.push_back(new MultiResolutionImageResourceFetcher(
- image_url, frame, 0, is_favicon ? WebURLRequest::RequestContextFavicon
- : WebURLRequest::RequestContextImage,
- bypass_cache ? WebCachePolicy::BypassingCache
- : WebCachePolicy::UseProtocolCachePolicy,
- base::Bind(&ImageDownloaderBase::DidFetchImage, base::Unretained(this),
- callback)));
+ image_fetchers_.push_back(
+ base::MakeUnique<MultiResolutionImageResourceFetcher>(
+ image_url, frame, 0,
+ is_favicon ? WebURLRequest::RequestContextFavicon
+ : WebURLRequest::RequestContextImage,
+ bypass_cache ? WebCachePolicy::BypassingCache
+ : WebCachePolicy::UseProtocolCachePolicy,
+ base::Bind(&ImageDownloaderBase::DidFetchImage,
+ base::Unretained(this), callback)));
return true;
}
@@ -111,11 +114,14 @@ void ImageDownloaderBase::DidFetchImage(
// Remove the image fetcher from our pending list. We're in the callback from
// MultiResolutionImageResourceFetcher, best to delay deletion.
- ImageResourceFetcherList::iterator iter =
- std::find(image_fetchers_.begin(), image_fetchers_.end(), fetcher);
- if (iter != image_fetchers_.end()) {
- image_fetchers_.weak_erase(iter);
- base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, fetcher);
+ for (auto iter = image_fetchers_.begin(); iter != image_fetchers_.end();
+ ++iter) {
+ if (iter->get() == fetcher) {
+ iter->release();
+ image_fetchers_.erase(iter);
+ base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, fetcher);
+ break;
+ }
}
// |this| may be destructed after callback is run.
@@ -123,7 +129,7 @@ void ImageDownloaderBase::DidFetchImage(
}
void ImageDownloaderBase::OnDestruct() {
- for (auto* fetchers : image_fetchers_) {
+ for (const auto& fetchers : image_fetchers_) {
// Will run callbacks with an empty image vector.
fetchers->OnRenderFrameDestruct();
}
« no previous file with comments | « content/renderer/image_downloader/image_downloader_base.h ('k') | content/renderer/media/audio_repetition_detector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698