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

Unified Diff: chrome/browser/android/banners/app_banner_manager.h

Issue 914813002: [App banners] Start addressing race conditions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 5 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: chrome/browser/android/banners/app_banner_manager.h
diff --git a/chrome/browser/android/banners/app_banner_manager.h b/chrome/browser/android/banners/app_banner_manager.h
index 9a8520c269cc211d55bc5a8b3c2a3de6dd8d09e0..60ac0d33ac1f01be081d9dbc5caf824ce56ca42f 100644
--- a/chrome/browser/android/banners/app_banner_manager.h
+++ b/chrome/browser/android/banners/app_banner_manager.h
@@ -67,9 +67,10 @@ class InfoBar;
namespace banners {
-class AppBannerManager : public chrome::BitmapFetcherDelegate,
- public content::WebContentsObserver {
+class AppBannerManager : public content::WebContentsObserver {
public:
+ class BannerBitmapFetcher;
+
AppBannerManager(JNIEnv* env, jobject obj);
~AppBannerManager() override;
@@ -94,8 +95,13 @@ class AppBannerManager : public chrome::BitmapFetcherDelegate,
// Returns |false| if this couldn't be kicked off.
bool FetchIcon(const GURL& image_url);
- // Return how many fetchers are active.
- int GetNumActiveFetchers(JNIEnv* env, jobject jobj);
+ // Called when everything required to show a banner is ready.
+ void OnFetchComplete(BannerBitmapFetcher* fetcher,
+ const GURL url,
+ const SkBitmap* icon);
+
+ // Return whether a BitmapFetcher is active.
+ bool IsFetcherActive(JNIEnv* env, jobject jobj);
// Returns the current time.
static base::Time GetCurrentTime();
@@ -108,9 +114,6 @@ class AppBannerManager : public chrome::BitmapFetcherDelegate,
const GURL& validated_url) override;
bool OnMessageReceived(const IPC::Message& message) override;
- // BitmapFetcherDelegate overrides.
- void OnFetchComplete(const GURL url, const SkBitmap* bitmap) override;
-
private:
// Gets the preferred icon size for the banner icons.
int GetPreferredIconSize();
@@ -138,8 +141,12 @@ class AppBannerManager : public chrome::BitmapFetcherDelegate,
// Check if the banner should be shown.
bool CheckIfShouldShow(const std::string& package_or_start_url);
- // Fetches the icon for an app.
- scoped_ptr<chrome::BitmapFetcher> fetcher_;
+ // Cancels an active BitmapFetcher, stopping its banner from appearing.
+ void CancelActiveFetcher();
+
+ // Fetches the icon for an app. Weakly held because they delete themselves.
+ BannerBitmapFetcher* fetcher_;
+
GURL validated_url_;
GURL app_icon_url_;

Powered by Google App Engine
This is Rietveld 408576698