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

Unified Diff: chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc

Issue 2768083004: Use OneShotTimer in AddToHomescreenDataFetcher (Closed)
Patch Set: Timer addressing comments Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
diff --git a/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc b/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
index a05a2037283710922947277e90a032e950490e79..1d4f270089ec3129b5b2eee6cf6b955703225733 100644
--- a/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
+++ b/chrome/browser/android/webapps/add_to_homescreen_data_fetcher.cc
@@ -36,6 +36,9 @@
namespace {
+// The default number of milliseconds to wait for the data download to complete.
+const int kDataTimeoutInMilliseconds = 4000;
+
// Looks up the original, online URL of the site requested. The URL from the
// WebContents may be a distilled article which is not appropriate for a home
// screen shortcut.
@@ -81,7 +84,6 @@ AddToHomescreenDataFetcher::AddToHomescreenDataFetcher(
weak_observer_(observer),
shortcut_info_(GetShortcutUrl(web_contents->GetBrowserContext(),
web_contents->GetLastCommittedURL())),
- data_timeout_timer_(false, false),
ideal_icon_size_in_px_(ideal_icon_size_in_px),
minimum_icon_size_in_px_(minimum_icon_size_in_px),
ideal_splash_image_size_in_px_(ideal_splash_image_size_in_px),
@@ -148,7 +150,7 @@ void AddToHomescreenDataFetcher::OnDidGetWebApplicationInfo(
// Kick off a timeout for downloading data. If we haven't finished within the
// timeout, fall back to using a dynamically-generated launcher icon.
data_timeout_timer_.Start(
- FROM_HERE, base::TimeDelta::FromMilliseconds(4000),
+ FROM_HERE, base::TimeDelta::FromMilliseconds(kDataTimeoutInMilliseconds),
base::Bind(&AddToHomescreenDataFetcher::OnDataTimedout, this));
manager->GetData(
@@ -191,14 +193,13 @@ void AddToHomescreenDataFetcher::OnDataTimedout() {
weak_observer_->OnUserTitleAvailable(base::string16());
}
- if (!is_icon_saved_) {
- badge_icon_.reset();
- CreateLauncherIcon(SkBitmap());
- }
+ badge_icon_.reset();
+ CreateLauncherIcon(SkBitmap());
}
void AddToHomescreenDataFetcher::OnDidPerformInstallableCheck(
const InstallableData& data) {
+ data_timeout_timer_.Stop();
badge_icon_.reset();
if (!web_contents() || !weak_observer_ || is_installable_check_complete_)
« no previous file with comments | « chrome/browser/android/webapps/add_to_homescreen_data_fetcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698