| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2012 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2012 Google Inc. All Rights Reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "core/workers/WorkerThread.h" | 41 #include "core/workers/WorkerThread.h" |
| 42 #include "platform/weborigin/SecurityPolicy.h" | 42 #include "platform/weborigin/SecurityPolicy.h" |
| 43 #include "wtf/PtrUtil.h" | 43 #include "wtf/PtrUtil.h" |
| 44 #include <memory> | 44 #include <memory> |
| 45 | 45 |
| 46 namespace blink { | 46 namespace blink { |
| 47 | 47 |
| 48 ExecutionContext::ExecutionContext() | 48 ExecutionContext::ExecutionContext() |
| 49 : m_circularSequentialID(0), | 49 : m_circularSequentialID(0), |
| 50 m_inDispatchErrorEvent(false), | 50 m_inDispatchErrorEvent(false), |
| 51 m_activeDOMObjectsAreSuspended(false), | 51 m_isContextSuspended(false), |
| 52 m_isContextDestroyed(false), | 52 m_isContextDestroyed(false), |
| 53 m_windowInteractionTokens(0), | 53 m_windowInteractionTokens(0), |
| 54 m_referrerPolicy(ReferrerPolicyDefault) {} | 54 m_referrerPolicy(ReferrerPolicyDefault) {} |
| 55 | 55 |
| 56 ExecutionContext::~ExecutionContext() {} | 56 ExecutionContext::~ExecutionContext() {} |
| 57 | 57 |
| 58 void ExecutionContext::suspendSuspendableObjects() { | 58 void ExecutionContext::suspendSuspendableObjects() { |
| 59 DCHECK(!m_activeDOMObjectsAreSuspended); | 59 DCHECK(!m_isContextSuspended); |
| 60 notifySuspendingSuspendableObjects(); | 60 notifySuspendingSuspendableObjects(); |
| 61 m_activeDOMObjectsAreSuspended = true; | 61 m_isContextSuspended = true; |
| 62 } | 62 } |
| 63 | 63 |
| 64 void ExecutionContext::resumeSuspendableObjects() { | 64 void ExecutionContext::resumeSuspendableObjects() { |
| 65 DCHECK(m_activeDOMObjectsAreSuspended); | 65 DCHECK(m_isContextSuspended); |
| 66 m_activeDOMObjectsAreSuspended = false; | 66 m_isContextSuspended = false; |
| 67 notifyResumingSuspendableObjects(); | 67 notifyResumingSuspendableObjects(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void ExecutionContext::notifyContextDestroyed() { | 70 void ExecutionContext::notifyContextDestroyed() { |
| 71 m_isContextDestroyed = true; | 71 m_isContextDestroyed = true; |
| 72 ContextLifecycleNotifier::notifyContextDestroyed(); | 72 ContextLifecycleNotifier::notifyContextDestroyed(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void ExecutionContext::suspendScheduledTasks() { | 75 void ExecutionContext::suspendScheduledTasks() { |
| 76 suspendSuspendableObjects(); | 76 suspendSuspendableObjects(); |
| 77 tasksWereSuspended(); | 77 tasksWereSuspended(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void ExecutionContext::resumeScheduledTasks() { | 80 void ExecutionContext::resumeScheduledTasks() { |
| 81 resumeSuspendableObjects(); | 81 resumeSuspendableObjects(); |
| 82 tasksWereResumed(); | 82 tasksWereResumed(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void ExecutionContext::suspendSuspendableObjectIfNeeded( | 85 void ExecutionContext::suspendSuspendableObjectIfNeeded( |
| 86 SuspendableObject* object) { | 86 SuspendableObject* object) { |
| 87 #if DCHECK_IS_ON() | 87 #if DCHECK_IS_ON() |
| 88 DCHECK(contains(object)); | 88 DCHECK(contains(object)); |
| 89 #endif | 89 #endif |
| 90 // Ensure all SuspendableObjects are suspended also newly created ones. | 90 // Ensure all SuspendableObjects are suspended also newly created ones. |
| 91 if (m_activeDOMObjectsAreSuspended) | 91 if (m_isContextSuspended) |
| 92 object->suspend(); | 92 object->suspend(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 bool ExecutionContext::shouldSanitizeScriptError( | 95 bool ExecutionContext::shouldSanitizeScriptError( |
| 96 const String& sourceURL, | 96 const String& sourceURL, |
| 97 AccessControlStatus corsStatus) { | 97 AccessControlStatus corsStatus) { |
| 98 if (corsStatus == OpaqueResource) | 98 if (corsStatus == OpaqueResource) |
| 99 return true; | 99 return true; |
| 100 return !(getSecurityOrigin()->canRequestNoSuborigin(completeURL(sourceURL)) || | 100 return !(getSecurityOrigin()->canRequestNoSuborigin(completeURL(sourceURL)) || |
| 101 corsStatus == SharableCrossOrigin); | 101 corsStatus == SharableCrossOrigin); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } | 246 } |
| 247 | 247 |
| 248 DEFINE_TRACE(ExecutionContext) { | 248 DEFINE_TRACE(ExecutionContext) { |
| 249 visitor->trace(m_publicURLManager); | 249 visitor->trace(m_publicURLManager); |
| 250 visitor->trace(m_pendingExceptions); | 250 visitor->trace(m_pendingExceptions); |
| 251 ContextLifecycleNotifier::trace(visitor); | 251 ContextLifecycleNotifier::trace(visitor); |
| 252 Supplementable<ExecutionContext>::trace(visitor); | 252 Supplementable<ExecutionContext>::trace(visitor); |
| 253 } | 253 } |
| 254 | 254 |
| 255 } // namespace blink | 255 } // namespace blink |
| OLD | NEW |