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

Side by Side Diff: chrome/browser/safe_browsing/srt_global_error_win.cc

Issue 2409443002: Make GlobalErrorService's ownership model slightly less insane. (Closed)
Patch Set: deprecation notice Created 4 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/safe_browsing/srt_global_error_win.h" 5 #include "chrome/browser/safe_browsing/srt_global_error_win.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 bool SRTGlobalError::ShouldCloseOnDeactivate() const { 214 bool SRTGlobalError::ShouldCloseOnDeactivate() const {
215 return false; 215 return false;
216 } 216 }
217 217
218 void SRTGlobalError::MaybeExecuteSRT() { 218 void SRTGlobalError::MaybeExecuteSRT() {
219 if (downloaded_path_.empty()) { 219 if (downloaded_path_.empty()) {
220 FallbackToDownloadPage(); 220 FallbackToDownloadPage();
221 return; 221 return;
222 } 222 }
223 // At this point, this object owns itself, since ownership has been taken back 223 // At this point, this object owns itself, since ownership has been taken back
224 // from the global_error_service_ in the call to RemoveGlobalError. This means 224 // from the global_error_service_ in the call to OnUserInteractionStarted.
225 // that it is safe to use base::Unretained here. 225 // This means that it is safe to use base::Unretained here.
226 BrowserThread::PostBlockingPoolTask( 226 BrowserThread::PostBlockingPoolTask(
227 FROM_HERE, 227 FROM_HERE,
228 base::Bind( 228 base::Bind(
229 &MaybeExecuteSRTFromBlockingPool, downloaded_path_, 229 &MaybeExecuteSRTFromBlockingPool, downloaded_path_,
230 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(), 230 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(),
231 bubble_shown_from_menu_ ? ChromePromptValue::kShownFromMenu 231 bubble_shown_from_menu_ ? ChromePromptValue::kShownFromMenu
232 : ChromePromptValue::kPrompted, 232 : ChromePromptValue::kPrompted,
233 base::ThreadTaskRunnerHandle::Get(), 233 base::ThreadTaskRunnerHandle::Get(),
234 base::Bind(&SRTGlobalError::OnUserinteractionDone, 234 base::Bind(&SRTGlobalError::OnUserinteractionDone,
235 base::Unretained(this)), 235 base::Unretained(this)),
(...skipping 19 matching lines...) Expand all
255 255
256 void SRTGlobalError::OnUserinteractionStarted( 256 void SRTGlobalError::OnUserinteractionStarted(
257 SRTPromptHistogramValue histogram_value) { 257 SRTPromptHistogramValue histogram_value) {
258 // This is for cases where the UI doesn't go away quickly enough and user 258 // This is for cases where the UI doesn't go away quickly enough and user
259 // might click on the button more than once, or more than one button. 259 // might click on the button more than once, or more than one button.
260 if (interacted_) 260 if (interacted_)
261 return; 261 return;
262 RecordSRTPromptHistogram(histogram_value); 262 RecordSRTPromptHistogram(histogram_value);
263 interacted_ = true; 263 interacted_ = true;
264 if (global_error_service_) { 264 if (global_error_service_) {
265 global_error_service_->RemoveGlobalError(this); 265 global_error_service_->RemoveGlobalError(this).release();
266 global_error_service_ = nullptr; 266 global_error_service_ = nullptr;
Nico 2016/12/13 15:54:14 isn't `this` dead after the release() call in the
Avi (use Gerrit) 2016/12/13 16:06:00 No; this is a release(), not a reset(). It's takin
267 } 267 }
268 } 268 }
269 269
270 void SRTGlobalError::OnUserinteractionDone() { 270 void SRTGlobalError::OnUserinteractionDone() {
271 DCHECK(interacted_); 271 DCHECK(interacted_);
272 // Once the user interacted with the bubble, we can forget about any pending 272 // Once the user interacted with the bubble, we can forget about any pending
273 // prompt. 273 // prompt.
274 g_browser_process->local_state()->SetBoolean(prefs::kSwReporterPendingPrompt, 274 g_browser_process->local_state()->SetBoolean(prefs::kSwReporterPendingPrompt,
275 false); 275 false);
276 delete this; 276 delete this;
277 } 277 }
278 278
279 } // namespace safe_browsing 279 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698