| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 } | 96 } |
| 97 | 97 |
| 98 WorkerOrWorkletScriptController::WorkerOrWorkletScriptController( | 98 WorkerOrWorkletScriptController::WorkerOrWorkletScriptController( |
| 99 WorkerOrWorkletGlobalScope* global_scope, | 99 WorkerOrWorkletGlobalScope* global_scope, |
| 100 v8::Isolate* isolate) | 100 v8::Isolate* isolate) |
| 101 : global_scope_(global_scope), | 101 : global_scope_(global_scope), |
| 102 isolate_(isolate), | 102 isolate_(isolate), |
| 103 execution_forbidden_(false), | 103 execution_forbidden_(false), |
| 104 rejected_promises_(RejectedPromises::Create()), | 104 rejected_promises_(RejectedPromises::Create()), |
| 105 execution_state_(0) { | 105 execution_state_(0) { |
| 106 ASSERT(isolate); | 106 DCHECK(isolate); |
| 107 world_ = | 107 world_ = |
| 108 DOMWrapperWorld::Create(isolate, DOMWrapperWorld::WorldType::kWorker); | 108 DOMWrapperWorld::Create(isolate, DOMWrapperWorld::WorldType::kWorker); |
| 109 } | 109 } |
| 110 | 110 |
| 111 WorkerOrWorkletScriptController::~WorkerOrWorkletScriptController() { | 111 WorkerOrWorkletScriptController::~WorkerOrWorkletScriptController() { |
| 112 ASSERT(!rejected_promises_); | 112 DCHECK(!rejected_promises_); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void WorkerOrWorkletScriptController::Dispose() { | 115 void WorkerOrWorkletScriptController::Dispose() { |
| 116 rejected_promises_->Dispose(); | 116 rejected_promises_->Dispose(); |
| 117 rejected_promises_.Release(); | 117 rejected_promises_.Release(); |
| 118 | 118 |
| 119 world_->Dispose(); | 119 world_->Dispose(); |
| 120 | 120 |
| 121 DisposeContextIfNeeded(); | 121 DisposeContextIfNeeded(); |
| 122 } | 122 } |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 state.exception, world_.Get()); | 332 state.exception, world_.Get()); |
| 333 } | 333 } |
| 334 global_scope_->DispatchErrorEvent(event, kNotSharableCrossOrigin); | 334 global_scope_->DispatchErrorEvent(event, kNotSharableCrossOrigin); |
| 335 } | 335 } |
| 336 return false; | 336 return false; |
| 337 } | 337 } |
| 338 return true; | 338 return true; |
| 339 } | 339 } |
| 340 | 340 |
| 341 void WorkerOrWorkletScriptController::ForbidExecution() { | 341 void WorkerOrWorkletScriptController::ForbidExecution() { |
| 342 ASSERT(global_scope_->IsContextThread()); | 342 DCHECK(global_scope_->IsContextThread()); |
| 343 execution_forbidden_ = true; | 343 execution_forbidden_ = true; |
| 344 } | 344 } |
| 345 | 345 |
| 346 bool WorkerOrWorkletScriptController::IsExecutionForbidden() const { | 346 bool WorkerOrWorkletScriptController::IsExecutionForbidden() const { |
| 347 ASSERT(global_scope_->IsContextThread()); | 347 DCHECK(global_scope_->IsContextThread()); |
| 348 return execution_forbidden_; | 348 return execution_forbidden_; |
| 349 } | 349 } |
| 350 | 350 |
| 351 void WorkerOrWorkletScriptController::DisableEval(const String& error_message) { | 351 void WorkerOrWorkletScriptController::DisableEval(const String& error_message) { |
| 352 disable_eval_pending_ = error_message; | 352 disable_eval_pending_ = error_message; |
| 353 } | 353 } |
| 354 | 354 |
| 355 void WorkerOrWorkletScriptController::RethrowExceptionFromImportedScript( | 355 void WorkerOrWorkletScriptController::RethrowExceptionFromImportedScript( |
| 356 ErrorEvent* error_event, | 356 ErrorEvent* error_event, |
| 357 ExceptionState& exception_state) { | 357 ExceptionState& exception_state) { |
| 358 const String& error_message = error_event->message(); | 358 const String& error_message = error_event->message(); |
| 359 if (execution_state_) | 359 if (execution_state_) |
| 360 execution_state_->error_event_from_imported_script_ = error_event; | 360 execution_state_->error_event_from_imported_script_ = error_event; |
| 361 exception_state.RethrowV8Exception( | 361 exception_state.RethrowV8Exception( |
| 362 V8ThrowException::CreateError(isolate_, error_message)); | 362 V8ThrowException::CreateError(isolate_, error_message)); |
| 363 } | 363 } |
| 364 | 364 |
| 365 DEFINE_TRACE(WorkerOrWorkletScriptController) { | 365 DEFINE_TRACE(WorkerOrWorkletScriptController) { |
| 366 visitor->Trace(global_scope_); | 366 visitor->Trace(global_scope_); |
| 367 } | 367 } |
| 368 | 368 |
| 369 } // namespace blink | 369 } // namespace blink |
| OLD | NEW |