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

Side by Side Diff: chrome/browser/ui/webui/crashes_ui.cc

Issue 23020015: In chrome://crashes, re-read the crash list on page reload (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: In chrome://crashes, re-read the crash list on page reload Created 7 years, 3 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 | chrome/browser/upload_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_;
92 bool js_request_pending_; 92 bool first_load_;
93 93
94 DISALLOW_COPY_AND_ASSIGN(CrashesDOMHandler); 94 DISALLOW_COPY_AND_ASSIGN(CrashesDOMHandler);
95 }; 95 };
96 96
97 CrashesDOMHandler::CrashesDOMHandler() 97 CrashesDOMHandler::CrashesDOMHandler()
98 : list_available_(false), js_request_pending_(false) { 98 : list_available_(false), first_load_(true) {
99 upload_list_ = CrashUploadList::Create(this); 99 upload_list_ = CrashUploadList::Create(this);
100 } 100 }
101 101
102 CrashesDOMHandler::~CrashesDOMHandler() { 102 CrashesDOMHandler::~CrashesDOMHandler() {
103 upload_list_->ClearDelegate(); 103 upload_list_->ClearDelegate();
104 } 104 }
105 105
106 void CrashesDOMHandler::RegisterMessages() { 106 void CrashesDOMHandler::RegisterMessages() {
107 upload_list_->LoadUploadListAsynchronously(); 107 upload_list_->LoadUploadListAsynchronously();
108
109 web_ui()->RegisterMessageCallback("requestCrashList", 108 web_ui()->RegisterMessageCallback("requestCrashList",
110 base::Bind(&CrashesDOMHandler::HandleRequestCrashes, 109 base::Bind(&CrashesDOMHandler::HandleRequestCrashes,
111 base::Unretained(this))); 110 base::Unretained(this)));
112 } 111 }
113 112
114 void CrashesDOMHandler::HandleRequestCrashes(const ListValue* args) { 113 void CrashesDOMHandler::HandleRequestCrashes(const ListValue* args) {
Lei Zhang 2013/09/17 20:33:15 I think this should be: if (first_load_) {
achaulk1 2013/09/17 21:21:51 Ah, you're right it would do that.
115 if (!CrashesUI::CrashReportingUIEnabled() || list_available_) 114 if (first_load_ && list_available_) {
116 UpdateUI(); 115 UpdateUI();
117 else 116 } else {
118 js_request_pending_ = true; 117 list_available_ = false;
118 upload_list_->LoadUploadListAsynchronously();
119 }
120 first_load_ = false;
119 } 121 }
120 122
121 void CrashesDOMHandler::OnUploadListAvailable() { 123 void CrashesDOMHandler::OnUploadListAvailable() {
122 list_available_ = true; 124 list_available_ = true;
123 if (js_request_pending_) 125 if (!first_load_)
124 UpdateUI(); 126 UpdateUI();
125 } 127 }
126 128
127 void CrashesDOMHandler::UpdateUI() { 129 void CrashesDOMHandler::UpdateUI() {
128 bool crash_reporting_enabled = CrashesUI::CrashReportingUIEnabled(); 130 bool crash_reporting_enabled = CrashesUI::CrashReportingUIEnabled();
129 ListValue crash_list; 131 ListValue crash_list;
130 132
131 if (crash_reporting_enabled) { 133 if (crash_reporting_enabled) {
132 std::vector<CrashUploadList::UploadInfo> crashes; 134 std::vector<CrashUploadList::UploadInfo> crashes;
133 upload_list_->GetUploads(50, &crashes); 135 upload_list_->GetUploads(50, &crashes);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 PrefService* prefs = g_browser_process->local_state(); 188 PrefService* prefs = g_browser_process->local_state();
187 return prefs->GetBoolean(prefs::kCrashReportingEnabled); 189 return prefs->GetBoolean(prefs::kCrashReportingEnabled);
188 #else 190 #else
189 PrefService* prefs = g_browser_process->local_state(); 191 PrefService* prefs = g_browser_process->local_state();
190 return prefs->GetBoolean(prefs::kMetricsReportingEnabled); 192 return prefs->GetBoolean(prefs::kMetricsReportingEnabled);
191 #endif 193 #endif
192 #else 194 #else
193 return false; 195 return false;
194 #endif 196 #endif
195 } 197 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/upload_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698