| OLD | NEW |
| 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 Loading... |
| 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 int64_t last_called_ts = 0; |
| 65 return ++total_crashes > kCrashesBeforeFeedbackIsDisplayed; | 66 base::TimeTicks last_called(base::TimeTicks::UnixEpoch()); |
| 67 |
| 68 if (last_called_ts) |
| 69 last_called = base::TimeTicks::FromInternalValue(last_called_ts); |
| 70 |
| 71 bool should_show = (base::TimeTicks().Now() - last_called).InSeconds() < |
| 72 kMinSecondsBetweenCrashesForFeedbackButton; |
| 73 |
| 74 last_called_ts = base::TimeTicks().Now().ToInternalValue(); |
| 75 return should_show; |
| 66 #else | 76 #else |
| 67 return false; | 77 return false; |
| 68 #endif | 78 #endif |
| 69 } | 79 } |
| 70 | 80 |
| 71 } // namespace | 81 } // namespace |
| 72 | 82 |
| 73 namespace chrome { | 83 namespace chrome { |
| 74 | 84 |
| 75 // static | 85 // static |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 // Fall through | 216 // Fall through |
| 207 case chrome::SAD_TAB_KIND_KILLED: | 217 case chrome::SAD_TAB_KIND_KILLED: |
| 208 UMA_SAD_TAB_COUNTER("Tabs.SadTab.KillCreated"); | 218 UMA_SAD_TAB_COUNTER("Tabs.SadTab.KillCreated"); |
| 209 LOG(WARNING) << "Tab Killed: " | 219 LOG(WARNING) << "Tab Killed: " |
| 210 << web_contents->GetURL().GetOrigin().spec(); | 220 << web_contents->GetURL().GetOrigin().spec(); |
| 211 break; | 221 break; |
| 212 } | 222 } |
| 213 } | 223 } |
| 214 | 224 |
| 215 } // namespace chrome | 225 } // namespace chrome |
| OLD | NEW |