| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/views/sad_tab_view.h" | 5 #include "chrome/browser/ui/views/sad_tab_view.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "ui/views/controls/button/label_button_border.h" | 27 #include "ui/views/controls/button/label_button_border.h" |
| 28 #include "ui/views/controls/image_view.h" | 28 #include "ui/views/controls/image_view.h" |
| 29 #include "ui/views/controls/label.h" | 29 #include "ui/views/controls/label.h" |
| 30 #include "ui/views/controls/link.h" | 30 #include "ui/views/controls/link.h" |
| 31 #include "ui/views/controls/styled_label.h" | 31 #include "ui/views/controls/styled_label.h" |
| 32 #include "ui/views/layout/grid_layout.h" | 32 #include "ui/views/layout/grid_layout.h" |
| 33 #include "ui/views/layout/layout_constants.h" | 33 #include "ui/views/layout/layout_constants.h" |
| 34 #include "ui/views/widget/widget.h" | 34 #include "ui/views/widget/widget.h" |
| 35 | 35 |
| 36 #if defined(OS_CHROMEOS) | 36 #if defined(OS_CHROMEOS) |
| 37 #include "chrome/browser/chromeos/memory/oom_memory_details.h" | 37 #include "chrome/browser/memory/oom_memory_details.h" |
| 38 #endif | 38 #endif |
| 39 | 39 |
| 40 using content::OpenURLParams; | 40 using content::OpenURLParams; |
| 41 using content::WebContents; | 41 using content::WebContents; |
| 42 | 42 |
| 43 namespace { | 43 namespace { |
| 44 | 44 |
| 45 const int kMaxContentWidth = 600; | 45 const int kMaxContentWidth = 600; |
| 46 const int kMinColumnWidth = 120; | 46 const int kMinColumnWidth = 120; |
| 47 const char kCategoryTagCrash[] = "Crash"; | 47 const char kCategoryTagCrash[] = "Crash"; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 painted_(false), | 84 painted_(false), |
| 85 message_(nullptr), | 85 message_(nullptr), |
| 86 help_link_(nullptr), | 86 help_link_(nullptr), |
| 87 feedback_link_(nullptr), | 87 feedback_link_(nullptr), |
| 88 reload_button_(nullptr), | 88 reload_button_(nullptr), |
| 89 title_(nullptr), | 89 title_(nullptr), |
| 90 help_message_(nullptr) { | 90 help_message_(nullptr) { |
| 91 DCHECK(web_contents); | 91 DCHECK(web_contents); |
| 92 | 92 |
| 93 // These stats should use the same counting approach and bucket size used for | 93 // These stats should use the same counting approach and bucket size used for |
| 94 // tab discard events in chromeos::OomPriorityManager so they can be | 94 // tab discard events in memory::OomPriorityManager so they can be directly |
| 95 // directly compared. | 95 // compared. |
| 96 // TODO(jamescook): Maybe track time between sad tabs? | 96 // TODO(jamescook): Maybe track time between sad tabs? |
| 97 switch (kind_) { | 97 switch (kind_) { |
| 98 case chrome::SAD_TAB_KIND_CRASHED: { | 98 case chrome::SAD_TAB_KIND_CRASHED: { |
| 99 static int crashed = 0; | 99 static int crashed = 0; |
| 100 crashed++; | 100 crashed++; |
| 101 UMA_HISTOGRAM_CUSTOM_COUNTS( | 101 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 102 "Tabs.SadTab.CrashCreated", crashed, 1, 1000, 50); | 102 "Tabs.SadTab.CrashCreated", crashed, 1, 1000, 50); |
| 103 break; | 103 break; |
| 104 } | 104 } |
| 105 case chrome::SAD_TAB_KIND_KILLED: { | 105 case chrome::SAD_TAB_KIND_KILLED: { |
| 106 RecordKillCreated(); | 106 RecordKillCreated(); |
| 107 LOG(WARNING) << "Tab Killed: " | 107 LOG(WARNING) << "Tab Killed: " |
| 108 << web_contents->GetURL().GetOrigin().spec(); | 108 << web_contents->GetURL().GetOrigin().spec(); |
| 109 break; | 109 break; |
| 110 } | 110 } |
| 111 #if defined(OS_CHROMEOS) | 111 #if defined(OS_CHROMEOS) |
| 112 case chrome::SAD_TAB_KIND_KILLED_BY_OOM: { | 112 case chrome::SAD_TAB_KIND_KILLED_BY_OOM: { |
| 113 RecordKillCreated(); | 113 RecordKillCreated(); |
| 114 RecordKillCreatedOOM(); | 114 RecordKillCreatedOOM(); |
| 115 const std::string spec = web_contents->GetURL().GetOrigin().spec(); | 115 const std::string spec = web_contents->GetURL().GetOrigin().spec(); |
| 116 chromeos::OomMemoryDetails::Log( | 116 memory::OomMemoryDetails::Log( |
| 117 "Tab OOM-Killed Memory details: " + spec + ", ", | 117 "Tab OOM-Killed Memory details: " + spec + ", ", base::Closure()); |
| 118 base::Closure()); | |
| 119 break; | 118 break; |
| 120 } | 119 } |
| 121 #endif | 120 #endif |
| 122 } | 121 } |
| 123 | 122 |
| 124 // Set the background color. | 123 // Set the background color. |
| 125 set_background( | 124 set_background( |
| 126 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( | 125 views::Background::CreateSolidBackground(GetNativeTheme()->GetSystemColor( |
| 127 ui::NativeTheme::kColorId_DialogBackground))); | 126 ui::NativeTheme::kColorId_DialogBackground))); |
| 128 | 127 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 | 289 |
| 291 if (help_message_ != nullptr) | 290 if (help_message_ != nullptr) |
| 292 help_message_->SizeToFit(max_width); | 291 help_message_->SizeToFit(max_width); |
| 293 | 292 |
| 294 View::Layout(); | 293 View::Layout(); |
| 295 } | 294 } |
| 296 | 295 |
| 297 void SadTabView::OnPaint(gfx::Canvas* canvas) { | 296 void SadTabView::OnPaint(gfx::Canvas* canvas) { |
| 298 if (!painted_) { | 297 if (!painted_) { |
| 299 // These stats should use the same counting approach and bucket size used | 298 // These stats should use the same counting approach and bucket size used |
| 300 // for tab discard events in chromeos::OomPriorityManager so they | 299 // for tab discard events in memory::OomPriorityManager so they can be |
| 301 // can be directly compared. | 300 // directly compared. |
| 302 switch (kind_) { | 301 switch (kind_) { |
| 303 case chrome::SAD_TAB_KIND_CRASHED: { | 302 case chrome::SAD_TAB_KIND_CRASHED: { |
| 304 static int crashed = 0; | 303 static int crashed = 0; |
| 305 UMA_HISTOGRAM_CUSTOM_COUNTS( | 304 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 306 "Tabs.SadTab.CrashDisplayed", ++crashed, 1, 1000, 50); | 305 "Tabs.SadTab.CrashDisplayed", ++crashed, 1, 1000, 50); |
| 307 break; | 306 break; |
| 308 } | 307 } |
| 309 case chrome::SAD_TAB_KIND_KILLED: | 308 case chrome::SAD_TAB_KIND_KILLED: |
| 310 RecordKillDisplayed(); | 309 RecordKillDisplayed(); |
| 311 break; | 310 break; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 } | 362 } |
| 364 | 363 |
| 365 namespace chrome { | 364 namespace chrome { |
| 366 | 365 |
| 367 SadTab* SadTab::Create(content::WebContents* web_contents, | 366 SadTab* SadTab::Create(content::WebContents* web_contents, |
| 368 SadTabKind kind) { | 367 SadTabKind kind) { |
| 369 return new SadTabView(web_contents, kind); | 368 return new SadTabView(web_contents, kind); |
| 370 } | 369 } |
| 371 | 370 |
| 372 } // namespace chrome | 371 } // namespace chrome |
| OLD | NEW |