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

Unified Diff: content/public/browser/screen_orientation_provider.cc

Issue 2630323002: [ScreenOrientation] Fix a possible crash point in ScreenOrientationProvider. (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/browser/screen_orientation_provider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/browser/screen_orientation_provider.cc
diff --git a/content/public/browser/screen_orientation_provider.cc b/content/public/browser/screen_orientation_provider.cc
index 1a5350ded026755d2ef97e76a021e641ae114e71..0a930d814813ef87072e4ee7e322cf92241df9f7 100644
--- a/content/public/browser/screen_orientation_provider.cc
+++ b/content/public/browser/screen_orientation_provider.cc
@@ -28,9 +28,9 @@ ScreenOrientationProvider::~ScreenOrientationProvider() {
void ScreenOrientationProvider::LockOrientation(
blink::WebScreenOrientationLockType orientation,
const LockOrientationCallback& callback) {
- // ScreenOrientation should have cancelled all pending request at this point.
- DCHECK(on_result_callback_.is_null());
leonhsl(Using Gerrit) 2017/01/16 11:00:18 Although ScreenOrientation have cancelled the pend
- DCHECK(!pending_lock_orientation_.has_value());
+ // ScreenOrientation should have already cancelled all pending request at this
+ // point, so we just clear pending status here without any actual operations.
+ pending_lock_orientation_.reset();
on_result_callback_ = callback;
if (!delegate_ || !delegate_->ScreenOrientationProviderSupported()) {
@@ -103,11 +103,9 @@ void ScreenOrientationProvider::OnOrientationChange() {
void ScreenOrientationProvider::NotifyLockResult(
ScreenOrientationLockResult result) {
- if (on_result_callback_.is_null()) {
- pending_lock_orientation_.reset();
- return;
+ if (!on_result_callback_.is_null()) {
+ base::ResetAndReturn(&on_result_callback_).Run(result);
}
- base::ResetAndReturn(&on_result_callback_).Run(result);
pending_lock_orientation_.reset();
}
« no previous file with comments | « content/public/browser/screen_orientation_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698