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

Side by Side Diff: chrome/browser/ui/sad_tab.cc

Issue 2885143009: Show feedback button on sad tab if sad tab has shown recently. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/sad_tab.h" 5 #include "chrome/browser/ui/sad_tab.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/time/time.h"
8 #include "chrome/browser/net/referrer.h" 9 #include "chrome/browser/net/referrer.h"
9 #include "chrome/browser/ui/browser_finder.h" 10 #include "chrome/browser/ui/browser_finder.h"
10 #include "chrome/browser/ui/chrome_pages.h" 11 #include "chrome/browser/ui/chrome_pages.h"
11 #include "chrome/common/url_constants.h" 12 #include "chrome/common/url_constants.h"
12 #include "chrome/grit/generated_resources.h" 13 #include "chrome/grit/generated_resources.h"
13 #include "components/feedback/feedback_util.h" 14 #include "components/feedback/feedback_util.h"
14 #include "components/strings/grit/components_strings.h" 15 #include "components/strings/grit/components_strings.h"
15 #include "content/public/browser/navigation_controller.h" 16 #include "content/public/browser/navigation_controller.h"
16 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
17 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 } else { 53 } else {
53 UMA_HISTOGRAM_ENUMERATION("Tabs.SadTab.Reload.Event", event, 54 UMA_HISTOGRAM_ENUMERATION("Tabs.SadTab.Reload.Event", event,
54 SadTabEvent::MAX_SAD_TAB_EVENT); 55 SadTabEvent::MAX_SAD_TAB_EVENT);
55 } 56 }
56 } 57 }
57 58
58 constexpr char kCategoryTagCrash[] = "Crash"; 59 constexpr char kCategoryTagCrash[] = "Crash";
59 60
60 bool ShouldShowFeedbackButton() { 61 bool ShouldShowFeedbackButton() {
61 #if defined(GOOGLE_CHROME_BUILD) 62 #if defined(GOOGLE_CHROME_BUILD)
62 const int kCrashesBeforeFeedbackIsDisplayed = 1; 63 const int kMinSecondsBetweenCrashesForFeedbackButton = 10;
63 64
64 static int total_crashes = 0; 65 static base::TimeTicks last_called = base::TimeTicks::UnixEpoch();
Will Harris 2017/05/18 00:58:08 static initalizer for this class is allowed?
sky 2017/05/18 16:37:58 Not sure on that, Nico likely knows.
Nico 2017/05/18 16:54:58 This is a function level static. Despite the simil
Will Harris 2017/05/18 22:59:47 Acknowledged. Changed to store the int64_t static
65 return ++total_crashes > kCrashesBeforeFeedbackIsDisplayed; 66
67 bool should_show = (base::TimeTicks().Now() - last_called).InSeconds() <
68 kMinSecondsBetweenCrashesForFeedbackButton;
69
70 last_called = base::TimeTicks().Now();
71 return should_show;
66 #else 72 #else
67 return false; 73 return false;
68 #endif 74 #endif
69 } 75 }
70 76
71 } // namespace 77 } // namespace
72 78
73 namespace chrome { 79 namespace chrome {
74 80
75 // static 81 // static
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 // Fall through 212 // Fall through
207 case chrome::SAD_TAB_KIND_KILLED: 213 case chrome::SAD_TAB_KIND_KILLED:
208 UMA_SAD_TAB_COUNTER("Tabs.SadTab.KillCreated"); 214 UMA_SAD_TAB_COUNTER("Tabs.SadTab.KillCreated");
209 LOG(WARNING) << "Tab Killed: " 215 LOG(WARNING) << "Tab Killed: "
210 << web_contents->GetURL().GetOrigin().spec(); 216 << web_contents->GetURL().GetOrigin().spec();
211 break; 217 break;
212 } 218 }
213 } 219 }
214 220
215 } // namespace chrome 221 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698