| 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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 #include "core/dom/ActiveDOMObject.h" | 27 #include "core/dom/ActiveDOMObject.h" |
| 28 | 28 |
| 29 #include "core/dom/ExecutionContext.h" | 29 #include "core/dom/ExecutionContext.h" |
| 30 #include "core/inspector/InstanceCounters.h" | 30 #include "core/inspector/InstanceCounters.h" |
| 31 | 31 |
| 32 namespace blink { | 32 namespace blink { |
| 33 | 33 |
| 34 ActiveDOMObject::ActiveDOMObject(ExecutionContext* executionContext) | 34 ActiveDOMObject::ActiveDOMObject(ExecutionContext* executionContext) |
| 35 : ContextLifecycleObserver(executionContext, ActiveDOMObjectType) | 35 : ContextLifecycleObserver(executionContext, ActiveDOMObjectType) |
| 36 #if ENABLE(ASSERT) | 36 #if DCHECK_IS_ON() |
| 37 , m_suspendIfNeededCalled(false) | 37 , m_suspendIfNeededCalled(false) |
| 38 #endif | 38 #endif |
| 39 { | 39 { |
| 40 ASSERT(!executionContext || executionContext->isContextThread()); | 40 DCHECK(!executionContext || executionContext->isContextThread()); |
| 41 // TODO(hajimehoshi): Now the leak detector can't treat vaious threads other | 41 // TODO(hajimehoshi): Now the leak detector can't treat vaious threads other |
| 42 // than the main thread and worker threads. After fixing the leak detector, | 42 // than the main thread and worker threads. After fixing the leak detector, |
| 43 // let's count objects on other threads as many as possible. | 43 // let's count objects on other threads as many as possible. |
| 44 if (isMainThread()) | 44 if (isMainThread()) |
| 45 InstanceCounters::incrementCounter(InstanceCounters::ActiveDOMObjectCoun
ter); | 45 InstanceCounters::incrementCounter(InstanceCounters::ActiveDOMObjectCoun
ter); |
| 46 } | 46 } |
| 47 | 47 |
| 48 ActiveDOMObject::~ActiveDOMObject() | 48 ActiveDOMObject::~ActiveDOMObject() |
| 49 { | 49 { |
| 50 if (isMainThread()) | 50 if (isMainThread()) |
| 51 InstanceCounters::decrementCounter(InstanceCounters::ActiveDOMObjectCoun
ter); | 51 InstanceCounters::decrementCounter(InstanceCounters::ActiveDOMObjectCoun
ter); |
| 52 | 52 |
| 53 ASSERT(m_suspendIfNeededCalled); | 53 #if DCHECK_IS_ON() |
| 54 DCHECK(m_suspendIfNeededCalled); |
| 55 #endif |
| 54 | 56 |
| 55 // Oilpan: not valid to access getExecutionContext() in the destructor. | 57 // Oilpan: not valid to access getExecutionContext() in the destructor. |
| 56 #if !ENABLE(OILPAN) | 58 #if !ENABLE(OILPAN) |
| 57 ASSERT(!getExecutionContext() || getExecutionContext()->isContextThread()); | 59 DCHECK(!getExecutionContext() || getExecutionContext()->isContextThread()); |
| 58 #endif | 60 #endif |
| 59 } | 61 } |
| 60 | 62 |
| 61 void ActiveDOMObject::suspendIfNeeded() | 63 void ActiveDOMObject::suspendIfNeeded() |
| 62 { | 64 { |
| 63 #if ENABLE(ASSERT) | 65 #if DCHECK_IS_ON() |
| 64 ASSERT(!m_suspendIfNeededCalled); | 66 DCHECK(!m_suspendIfNeededCalled); |
| 65 m_suspendIfNeededCalled = true; | 67 m_suspendIfNeededCalled = true; |
| 66 #endif | 68 #endif |
| 67 if (ExecutionContext* context = getExecutionContext()) | 69 if (ExecutionContext* context = getExecutionContext()) |
| 68 context->suspendActiveDOMObjectIfNeeded(this); | 70 context->suspendActiveDOMObjectIfNeeded(this); |
| 69 } | 71 } |
| 70 | 72 |
| 71 void ActiveDOMObject::suspend() | 73 void ActiveDOMObject::suspend() |
| 72 { | 74 { |
| 73 } | 75 } |
| 74 | 76 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 91 | 93 |
| 92 if (context->activeDOMObjectsAreSuspended()) { | 94 if (context->activeDOMObjectsAreSuspended()) { |
| 93 suspend(); | 95 suspend(); |
| 94 return; | 96 return; |
| 95 } | 97 } |
| 96 | 98 |
| 97 resume(); | 99 resume(); |
| 98 } | 100 } |
| 99 | 101 |
| 100 } // namespace blink | 102 } // namespace blink |
| OLD | NEW |