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

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

Issue 341083008: [AiS] Fix ownership issue for image service observers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@img-bridge
Patch Set: Re-upload. Created 6 years, 6 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 "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" 8 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "net/base/load_flags.h" 10 #include "net/base/load_flags.h"
(...skipping 27 matching lines...) Expand all
38 DISALLOW_COPY_AND_ASSIGN(BitmapFetcherRequest); 38 DISALLOW_COPY_AND_ASSIGN(BitmapFetcherRequest);
39 }; 39 };
40 40
41 BitmapFetcherRequest::BitmapFetcherRequest( 41 BitmapFetcherRequest::BitmapFetcherRequest(
42 BitmapFetcherService::RequestId request_id, 42 BitmapFetcherService::RequestId request_id,
43 BitmapFetcherService::Observer* observer) 43 BitmapFetcherService::Observer* observer)
44 : request_id_(request_id), observer_(observer) { 44 : request_id_(request_id), observer_(observer) {
45 } 45 }
46 46
47 BitmapFetcherRequest::~BitmapFetcherRequest() { 47 BitmapFetcherRequest::~BitmapFetcherRequest() {
48 SkBitmap empty_bitmap;
49
50 // OnImageChanged with an empty bitmap signifies a completed request.
51 observer_->OnImageChanged(request_id_, empty_bitmap);
52 } 48 }
53 49
54 void BitmapFetcherRequest::NotifyImageChanged(const SkBitmap& bitmap) { 50 void BitmapFetcherRequest::NotifyImageChanged(const SkBitmap& bitmap) {
55 if (!bitmap.empty()) 51 if (!bitmap.empty())
56 observer_->OnImageChanged(request_id_, bitmap); 52 observer_->OnImageChanged(request_id_, bitmap);
57 } 53 }
58 54
59 BitmapFetcherService::CacheEntry::CacheEntry() { 55 BitmapFetcherService::CacheEntry::CacheEntry() {
60 } 56 }
61 57
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 178 }
183 179
184 if (!bitmap->isNull()) { 180 if (!bitmap->isNull()) {
185 CacheEntry* entry = new CacheEntry; 181 CacheEntry* entry = new CacheEntry;
186 entry->bitmap.reset(new SkBitmap(*bitmap)); 182 entry->bitmap.reset(new SkBitmap(*bitmap));
187 cache_.Put(fetcher->url(), entry); 183 cache_.Put(fetcher->url(), entry);
188 } 184 }
189 185
190 RemoveFetcher(fetcher); 186 RemoveFetcher(fetcher);
191 } 187 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698