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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/RejectedPromises.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/RejectedPromises.h" 5 #include "bindings/core/v8/RejectedPromises.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "bindings/core/v8/ScopedPersistent.h" 8 #include "bindings/core/v8/ScopedPersistent.h"
9 #include "bindings/core/v8/ScriptState.h" 9 #include "bindings/core/v8/ScriptState.h"
10 #include "bindings/core/v8/ScriptValue.h" 10 #include "bindings/core/v8/ScriptValue.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 if (!execution_context) 56 if (!execution_context)
57 return; 57 return;
58 58
59 ScriptState::Scope scope(script_state_); 59 ScriptState::Scope scope(script_state_);
60 v8::Local<v8::Value> value = promise_.NewLocal(script_state_->GetIsolate()); 60 v8::Local<v8::Value> value = promise_.NewLocal(script_state_->GetIsolate());
61 v8::Local<v8::Value> reason = 61 v8::Local<v8::Value> reason =
62 exception_.NewLocal(script_state_->GetIsolate()); 62 exception_.NewLocal(script_state_->GetIsolate());
63 // Either collected or https://crbug.com/450330 63 // Either collected or https://crbug.com/450330
64 if (value.IsEmpty() || !value->IsPromise()) 64 if (value.IsEmpty() || !value->IsPromise())
65 return; 65 return;
66 ASSERT(!HasHandler()); 66 DCHECK(!HasHandler());
67 67
68 EventTarget* target = execution_context->ErrorEventTarget(); 68 EventTarget* target = execution_context->ErrorEventTarget();
69 if (target && !execution_context->ShouldSanitizeScriptError(resource_name_, 69 if (target && !execution_context->ShouldSanitizeScriptError(resource_name_,
70 cors_status_)) { 70 cors_status_)) {
71 PromiseRejectionEventInit init; 71 PromiseRejectionEventInit init;
72 init.setPromise(ScriptPromise(script_state_, value)); 72 init.setPromise(ScriptPromise(script_state_, value));
73 init.setReason(ScriptValue(script_state_, reason)); 73 init.setReason(ScriptValue(script_state_, reason));
74 init.setCancelable(true); 74 init.setCancelable(true);
75 PromiseRejectionEvent* event = PromiseRejectionEvent::Create( 75 PromiseRejectionEvent* event = PromiseRejectionEvent::Create(
76 script_state_, EventTypeNames::unhandledrejection, init); 76 script_state_, EventTypeNames::unhandledrejection, init);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 ThreadDebugger* debugger = 120 ThreadDebugger* debugger =
121 ThreadDebugger::From(script_state_->GetIsolate()); 121 ThreadDebugger::From(script_state_->GetIsolate());
122 if (debugger) { 122 if (debugger) {
123 debugger->PromiseRejectionRevoked(script_state_->GetContext(), 123 debugger->PromiseRejectionRevoked(script_state_->GetContext(),
124 promise_rejection_id_); 124 promise_rejection_id_);
125 } 125 }
126 } 126 }
127 } 127 }
128 128
129 void MakePromiseWeak() { 129 void MakePromiseWeak() {
130 ASSERT(!promise_.IsEmpty() && !promise_.IsWeak()); 130 DCHECK(!promise_.IsEmpty() && !promise_.IsWeak());
tkent 2017/04/13 05:37:16 Split this into two DCHECKs. DCHECK(!promise_.IsE
bhagirathi.s 2017/04/13 09:10:35 Done.
131 promise_.SetWeak(this, &Message::DidCollectPromise); 131 promise_.SetWeak(this, &Message::DidCollectPromise);
132 exception_.SetWeak(this, &Message::DidCollectException); 132 exception_.SetWeak(this, &Message::DidCollectException);
133 } 133 }
134 134
135 void MakePromiseStrong() { 135 void MakePromiseStrong() {
136 ASSERT(!promise_.IsEmpty() && promise_.IsWeak()); 136 DCHECK(!promise_.IsEmpty() && promise_.IsWeak());
tkent 2017/04/13 05:37:16 Ditto.
bhagirathi.s 2017/04/13 09:10:35 Done.
137 promise_.ClearWeak(); 137 promise_.ClearWeak();
138 exception_.ClearWeak(); 138 exception_.ClearWeak();
139 } 139 }
140 140
141 bool HasHandler() { 141 bool HasHandler() {
142 ASSERT(!IsCollected()); 142 DCHECK(!IsCollected());
143 ScriptState::Scope scope(script_state_); 143 ScriptState::Scope scope(script_state_);
144 v8::Local<v8::Value> value = promise_.NewLocal(script_state_->GetIsolate()); 144 v8::Local<v8::Value> value = promise_.NewLocal(script_state_->GetIsolate());
145 return v8::Local<v8::Promise>::Cast(value)->HasHandler(); 145 return v8::Local<v8::Promise>::Cast(value)->HasHandler();
146 } 146 }
147 147
148 private: 148 private:
149 Message(ScriptState* script_state, 149 Message(ScriptState* script_state,
150 v8::Local<v8::Promise> promise, 150 v8::Local<v8::Promise> promise,
151 v8::Local<v8::Value> exception, 151 v8::Local<v8::Value> exception,
152 const String& error_message, 152 const String& error_message,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 kMaxReportedHandlersPendingResolution / 10); 279 kMaxReportedHandlersPendingResolution / 10);
280 } 280 }
281 } 281 }
282 } 282 }
283 283
284 void RejectedPromises::RevokeNow(std::unique_ptr<Message> message) { 284 void RejectedPromises::RevokeNow(std::unique_ptr<Message> message) {
285 message->Revoke(); 285 message->Revoke();
286 } 286 }
287 287
288 } // namespace blink 288 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698