| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // let's count objects on other threads as many as possible. | 44 // let's count objects on other threads as many as possible. |
| 45 if (isMainThread()) | 45 if (isMainThread()) |
| 46 InstanceCounters::incrementCounter(InstanceCounters::ActiveDOMObjectCoun
ter); | 46 InstanceCounters::incrementCounter(InstanceCounters::ActiveDOMObjectCoun
ter); |
| 47 } | 47 } |
| 48 | 48 |
| 49 ActiveDOMObject::~ActiveDOMObject() | 49 ActiveDOMObject::~ActiveDOMObject() |
| 50 { | 50 { |
| 51 if (isMainThread()) | 51 if (isMainThread()) |
| 52 InstanceCounters::decrementCounter(InstanceCounters::ActiveDOMObjectCoun
ter); | 52 InstanceCounters::decrementCounter(InstanceCounters::ActiveDOMObjectCoun
ter); |
| 53 | 53 |
| 54 // ActiveDOMObject may be inherited by a sub-class whose life-cycle | 54 ASSERT(m_suspendIfNeededCalled); |
| 55 // exceeds that of the associated ExecutionContext. In those cases, | |
| 56 // m_executionContext would/should have been nullified by | |
| 57 // ContextLifecycleObserver::contextDestroyed() (which we implement / | |
| 58 // inherit). Hence, we should ensure that this is not 0 before use it | |
| 59 // here. | |
| 60 if (!executionContext()) | |
| 61 return; | |
| 62 | 55 |
| 63 ASSERT(m_suspendIfNeededCalled); | 56 // Oilpan: not valid to access executionContext() in the destructor. |
| 64 #if !ENABLE(OILPAN) | 57 #if !ENABLE(OILPAN) |
| 65 ASSERT(executionContext()->isContextThread()); | 58 ASSERT(!executionContext() || executionContext()->isContextThread()); |
| 66 #endif | 59 #endif |
| 67 } | 60 } |
| 68 | 61 |
| 69 void ActiveDOMObject::suspendIfNeeded() | 62 void ActiveDOMObject::suspendIfNeeded() |
| 70 { | 63 { |
| 71 #if ENABLE(ASSERT) | 64 #if ENABLE(ASSERT) |
| 72 ASSERT(!m_suspendIfNeededCalled); | 65 ASSERT(!m_suspendIfNeededCalled); |
| 73 m_suspendIfNeededCalled = true; | 66 m_suspendIfNeededCalled = true; |
| 74 #endif | 67 #endif |
| 75 if (ExecutionContext* context = executionContext()) | 68 if (ExecutionContext* context = executionContext()) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 104 | 97 |
| 105 if (context->activeDOMObjectsAreSuspended()) { | 98 if (context->activeDOMObjectsAreSuspended()) { |
| 106 suspend(); | 99 suspend(); |
| 107 return; | 100 return; |
| 108 } | 101 } |
| 109 | 102 |
| 110 resume(); | 103 resume(); |
| 111 } | 104 } |
| 112 | 105 |
| 113 } // namespace blink | 106 } // namespace blink |
| OLD | NEW |