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 16 matching lines...) Expand all Loading... |
27 #include "config.h" | 27 #include "config.h" |
28 #include "core/dom/ActiveDOMObject.h" | 28 #include "core/dom/ActiveDOMObject.h" |
29 | 29 |
30 #include "core/dom/ExecutionContext.h" | 30 #include "core/dom/ExecutionContext.h" |
31 | 31 |
32 namespace WebCore { | 32 namespace WebCore { |
33 | 33 |
34 ActiveDOMObject::ActiveDOMObject(ExecutionContext* executionContext) | 34 ActiveDOMObject::ActiveDOMObject(ExecutionContext* executionContext) |
35 : ContextLifecycleObserver(executionContext, ActiveDOMObjectType) | 35 : ContextLifecycleObserver(executionContext, ActiveDOMObjectType) |
36 , m_pendingActivityCount(0) | 36 , m_pendingActivityCount(0) |
37 #if !ASSERT_DISABLED | 37 #if ASSERT_ENABLED |
38 , m_suspendIfNeededCalled(false) | 38 , m_suspendIfNeededCalled(false) |
39 #endif | 39 #endif |
40 { | 40 { |
41 ASSERT(!executionContext || executionContext->isContextThread()); | 41 ASSERT(!executionContext || executionContext->isContextThread()); |
42 } | 42 } |
43 | 43 |
44 ActiveDOMObject::~ActiveDOMObject() | 44 ActiveDOMObject::~ActiveDOMObject() |
45 { | 45 { |
46 // ActiveDOMObject may be inherited by a sub-class whose life-cycle | 46 // ActiveDOMObject may be inherited by a sub-class whose life-cycle |
47 // exceeds that of the associated ExecutionContext. In those cases, | 47 // exceeds that of the associated ExecutionContext. In those cases, |
48 // m_executionContext would/should have been nullified by | 48 // m_executionContext would/should have been nullified by |
49 // ContextLifecycleObserver::contextDestroyed() (which we implement / | 49 // ContextLifecycleObserver::contextDestroyed() (which we implement / |
50 // inherit). Hence, we should ensure that this is not 0 before use it | 50 // inherit). Hence, we should ensure that this is not 0 before use it |
51 // here. | 51 // here. |
52 if (!executionContext()) | 52 if (!executionContext()) |
53 return; | 53 return; |
54 | 54 |
55 ASSERT(m_suspendIfNeededCalled); | 55 ASSERT(m_suspendIfNeededCalled); |
56 ASSERT(executionContext()->isContextThread()); | 56 ASSERT(executionContext()->isContextThread()); |
57 } | 57 } |
58 | 58 |
59 void ActiveDOMObject::suspendIfNeeded() | 59 void ActiveDOMObject::suspendIfNeeded() |
60 { | 60 { |
61 #if !ASSERT_DISABLED | 61 #if ASSERT_ENABLED |
62 ASSERT(!m_suspendIfNeededCalled); | 62 ASSERT(!m_suspendIfNeededCalled); |
63 m_suspendIfNeededCalled = true; | 63 m_suspendIfNeededCalled = true; |
64 #endif | 64 #endif |
65 if (ExecutionContext* context = executionContext()) | 65 if (ExecutionContext* context = executionContext()) |
66 context->suspendActiveDOMObjectIfNeeded(this); | 66 context->suspendActiveDOMObjectIfNeeded(this); |
67 } | 67 } |
68 | 68 |
69 bool ActiveDOMObject::hasPendingActivity() const | 69 bool ActiveDOMObject::hasPendingActivity() const |
70 { | 70 { |
71 return m_pendingActivityCount; | 71 return m_pendingActivityCount; |
(...skipping 22 matching lines...) Expand all Loading... |
94 | 94 |
95 if (context->activeDOMObjectsAreSuspended()) { | 95 if (context->activeDOMObjectsAreSuspended()) { |
96 suspend(); | 96 suspend(); |
97 return; | 97 return; |
98 } | 98 } |
99 | 99 |
100 resume(); | 100 resume(); |
101 } | 101 } |
102 | 102 |
103 } // namespace WebCore | 103 } // namespace WebCore |
OLD | NEW |