 Chromium Code Reviews
 Chromium Code Reviews Issue 23020015:
  In chrome://crashes, re-read the crash list on page reload  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 23020015:
  In chrome://crashes, re-read the crash list on page reload  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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/webui/crashes_ui.h" | 5 #include "chrome/browser/ui/webui/crashes_ui.h" | 
| 6 | 6 | 
| 7 #include <vector> | 7 #include <vector> | 
| 8 | 8 | 
| 9 #include "base/bind.h" | 9 #include "base/bind.h" | 
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" | 
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 virtual void OnUploadListAvailable() OVERRIDE; | 81 virtual void OnUploadListAvailable() OVERRIDE; | 
| 82 | 82 | 
| 83 private: | 83 private: | 
| 84 // Asynchronously fetches the list of crashes. Called from JS. | 84 // Asynchronously fetches the list of crashes. Called from JS. | 
| 85 void HandleRequestCrashes(const ListValue* args); | 85 void HandleRequestCrashes(const ListValue* args); | 
| 86 | 86 | 
| 87 // Sends the recent crashes list JS. | 87 // Sends the recent crashes list JS. | 
| 88 void UpdateUI(); | 88 void UpdateUI(); | 
| 89 | 89 | 
| 90 scoped_refptr<CrashUploadList> upload_list_; | 90 scoped_refptr<CrashUploadList> upload_list_; | 
| 91 bool list_available_; | 91 bool list_available_; | 
| 
vapier
2013/09/14 04:43:39
pretty sure this is now unused
 
achaulk1
2013/09/16 18:06:21
Ah, yes it is
 | |
| 92 bool js_request_pending_; | |
| 93 | 92 | 
| 94 DISALLOW_COPY_AND_ASSIGN(CrashesDOMHandler); | 93 DISALLOW_COPY_AND_ASSIGN(CrashesDOMHandler); | 
| 95 }; | 94 }; | 
| 96 | 95 | 
| 97 CrashesDOMHandler::CrashesDOMHandler() | 96 CrashesDOMHandler::CrashesDOMHandler() | 
| 98 : list_available_(false), js_request_pending_(false) { | 97 : list_available_(false) { | 
| 99 upload_list_ = CrashUploadList::Create(this); | 98 upload_list_ = CrashUploadList::Create(this); | 
| 100 } | 99 } | 
| 101 | 100 | 
| 102 CrashesDOMHandler::~CrashesDOMHandler() { | 101 CrashesDOMHandler::~CrashesDOMHandler() { | 
| 103 upload_list_->ClearDelegate(); | 102 upload_list_->ClearDelegate(); | 
| 104 } | 103 } | 
| 105 | 104 | 
| 106 void CrashesDOMHandler::RegisterMessages() { | 105 void CrashesDOMHandler::RegisterMessages() { | 
| 107 upload_list_->LoadUploadListAsynchronously(); | |
| 108 | |
| 109 web_ui()->RegisterMessageCallback("requestCrashList", | 106 web_ui()->RegisterMessageCallback("requestCrashList", | 
| 110 base::Bind(&CrashesDOMHandler::HandleRequestCrashes, | 107 base::Bind(&CrashesDOMHandler::HandleRequestCrashes, | 
| 111 base::Unretained(this))); | 108 base::Unretained(this))); | 
| 112 } | 109 } | 
| 113 | 110 | 
| 114 void CrashesDOMHandler::HandleRequestCrashes(const ListValue* args) { | 111 void CrashesDOMHandler::HandleRequestCrashes(const ListValue* args) { | 
| 115 if (!CrashesUI::CrashReportingUIEnabled() || list_available_) | 112 upload_list_->LoadUploadListAsynchronously(); | 
| 116 UpdateUI(); | |
| 117 else | |
| 118 js_request_pending_ = true; | |
| 119 } | 113 } | 
| 120 | 114 | 
| 121 void CrashesDOMHandler::OnUploadListAvailable() { | 115 void CrashesDOMHandler::OnUploadListAvailable() { | 
| 122 list_available_ = true; | 116 list_available_ = true; | 
| 123 if (js_request_pending_) | 117 UpdateUI(); | 
| 124 UpdateUI(); | |
| 125 } | 118 } | 
| 126 | 119 | 
| 127 void CrashesDOMHandler::UpdateUI() { | 120 void CrashesDOMHandler::UpdateUI() { | 
| 128 bool crash_reporting_enabled = CrashesUI::CrashReportingUIEnabled(); | 121 bool crash_reporting_enabled = CrashesUI::CrashReportingUIEnabled(); | 
| 129 ListValue crash_list; | 122 ListValue crash_list; | 
| 130 | 123 | 
| 131 if (crash_reporting_enabled) { | 124 if (crash_reporting_enabled) { | 
| 132 std::vector<CrashUploadList::UploadInfo> crashes; | 125 std::vector<CrashUploadList::UploadInfo> crashes; | 
| 133 upload_list_->GetUploads(50, &crashes); | 126 upload_list_->GetUploads(50, &crashes); | 
| 134 | 127 | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 PrefService* prefs = g_browser_process->local_state(); | 179 PrefService* prefs = g_browser_process->local_state(); | 
| 187 return prefs->GetBoolean(prefs::kCrashReportingEnabled); | 180 return prefs->GetBoolean(prefs::kCrashReportingEnabled); | 
| 188 #else | 181 #else | 
| 189 PrefService* prefs = g_browser_process->local_state(); | 182 PrefService* prefs = g_browser_process->local_state(); | 
| 190 return prefs->GetBoolean(prefs::kMetricsReportingEnabled); | 183 return prefs->GetBoolean(prefs::kMetricsReportingEnabled); | 
| 191 #endif | 184 #endif | 
| 192 #else | 185 #else | 
| 193 return false; | 186 return false; | 
| 194 #endif | 187 #endif | 
| 195 } | 188 } | 
| OLD | NEW |