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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptPromiseResolver.cpp

Issue 2817533003: Replace ASSERT, RELEASE_ASSERT, and ASSERT_NOT_REACHED in bindings (Closed)
Patch Set: Created 3 years, 8 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
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 "bindings/core/v8/ScriptPromiseResolver.h" 5 #include "bindings/core/v8/ScriptPromiseResolver.h"
6 6
7 #include "core/dom/TaskRunnerHelper.h" 7 #include "core/dom/TaskRunnerHelper.h"
8 #include "core/probe/CoreProbes.h" 8 #include "core/probe/CoreProbes.h"
9 9
10 namespace blink { 10 namespace blink {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // is then resolved/rejected while in that suspended state. 50 // is then resolved/rejected while in that suspended state.
51 if (state_ == kDetached || keep_alive_) 51 if (state_ == kDetached || keep_alive_)
52 return; 52 return;
53 53
54 // Keep |this| around while the promise is Pending; 54 // Keep |this| around while the promise is Pending;
55 // see detach() for the dual operation. 55 // see detach() for the dual operation.
56 keep_alive_ = this; 56 keep_alive_ = this;
57 } 57 }
58 58
59 void ScriptPromiseResolver::OnTimerFired(TimerBase*) { 59 void ScriptPromiseResolver::OnTimerFired(TimerBase*) {
60 ASSERT(state_ == kResolving || state_ == kRejecting); 60 DCHECK(state_ == kResolving || state_ == kRejecting);
61 if (!GetScriptState()->ContextIsValid()) { 61 if (!GetScriptState()->ContextIsValid()) {
62 Detach(); 62 Detach();
63 return; 63 return;
64 } 64 }
65 65
66 ScriptState::Scope scope(script_state_.Get()); 66 ScriptState::Scope scope(script_state_.Get());
67 ResolveOrRejectImmediately(); 67 ResolveOrRejectImmediately();
68 } 68 }
69 69
70 void ScriptPromiseResolver::ResolveOrRejectImmediately() { 70 void ScriptPromiseResolver::ResolveOrRejectImmediately() {
71 DCHECK(!GetExecutionContext()->IsContextDestroyed()); 71 DCHECK(!GetExecutionContext()->IsContextDestroyed());
72 DCHECK(!GetExecutionContext()->IsContextSuspended()); 72 DCHECK(!GetExecutionContext()->IsContextSuspended());
73 { 73 {
74 probe::AsyncTask async_task(GetExecutionContext(), this); 74 probe::AsyncTask async_task(GetExecutionContext(), this);
75 if (state_ == kResolving) { 75 if (state_ == kResolving) {
76 resolver_.Resolve(value_.NewLocal(script_state_->GetIsolate())); 76 resolver_.Resolve(value_.NewLocal(script_state_->GetIsolate()));
77 } else { 77 } else {
78 ASSERT(state_ == kRejecting); 78 ASSERT(state_ == kRejecting);
79 resolver_.Reject(value_.NewLocal(script_state_->GetIsolate())); 79 resolver_.Reject(value_.NewLocal(script_state_->GetIsolate()));
80 } 80 }
81 } 81 }
82 Detach(); 82 Detach();
83 } 83 }
84 84
85 DEFINE_TRACE(ScriptPromiseResolver) { 85 DEFINE_TRACE(ScriptPromiseResolver) {
86 SuspendableObject::Trace(visitor); 86 SuspendableObject::Trace(visitor);
87 } 87 }
88 88
89 } // namespace blink 89 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698