| OLD | NEW |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 ScriptState::Scope scope(script_state_); | 45 ScriptState::Scope scope(script_state_); |
| 46 return promise == promise_.NewLocal(script_state_->GetIsolate()); | 46 return promise == promise_.NewLocal(script_state_->GetIsolate()); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void Report() { | 49 void Report() { |
| 50 if (!script_state_->ContextIsValid()) | 50 if (!script_state_->ContextIsValid()) |
| 51 return; | 51 return; |
| 52 // If execution termination has been triggered, quietly bail out. | 52 // If execution termination has been triggered, quietly bail out. |
| 53 if (script_state_->GetIsolate()->IsExecutionTerminating()) | 53 if (script_state_->GetIsolate()->IsExecutionTerminating()) |
| 54 return; | 54 return; |
| 55 ExecutionContext* execution_context = script_state_->GetExecutionContext(); | 55 ExecutionContext* execution_context = ExecutionContext::From(script_state_); |
| 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; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 86 promise_rejection_id_ = debugger->PromiseRejected( | 86 promise_rejection_id_ = debugger->PromiseRejected( |
| 87 script_state_->GetContext(), error_message_, reason, | 87 script_state_->GetContext(), error_message_, reason, |
| 88 std::move(location_)); | 88 std::move(location_)); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 location_.reset(); | 92 location_.reset(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void Revoke() { | 95 void Revoke() { |
| 96 ExecutionContext* execution_context = script_state_->GetExecutionContext(); | 96 ExecutionContext* execution_context = ExecutionContext::From(script_state_); |
| 97 if (!execution_context) | 97 if (!execution_context) |
| 98 return; | 98 return; |
| 99 | 99 |
| 100 ScriptState::Scope scope(script_state_); | 100 ScriptState::Scope scope(script_state_); |
| 101 v8::Local<v8::Value> value = promise_.NewLocal(script_state_->GetIsolate()); | 101 v8::Local<v8::Value> value = promise_.NewLocal(script_state_->GetIsolate()); |
| 102 v8::Local<v8::Value> reason = | 102 v8::Local<v8::Value> reason = |
| 103 exception_.NewLocal(script_state_->GetIsolate()); | 103 exception_.NewLocal(script_state_->GetIsolate()); |
| 104 // Either collected or https://crbug.com/450330 | 104 // Either collected or https://crbug.com/450330 |
| 105 if (value.IsEmpty() || !value->IsPromise()) | 105 if (value.IsEmpty() || !value->IsPromise()) |
| 106 return; | 106 return; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |