| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // ExecutionContext is not yet detached. This is a work-around | 177 // ExecutionContext is not yet detached. This is a work-around |
| 178 // to avoid memory leaks caused by hasPendingActivity that keeps | 178 // to avoid memory leaks caused by hasPendingActivity that keeps |
| 179 // returning true forever. This will be okay in practice because | 179 // returning true forever. This will be okay in practice because |
| 180 // the spec requires to stop almost all DOM activities when the | 180 // the spec requires to stop almost all DOM activities when the |
| 181 // associated browsing context is detached. However, the real | 181 // associated browsing context is detached. However, the real |
| 182 // problem is that some hasPendingActivity's are wrongly implemented | 182 // problem is that some hasPendingActivity's are wrongly implemented |
| 183 // and never return false. | 183 // and never return false. |
| 184 // TODO(haraken): Implement correct lifetime using traceWrapper. | 184 // TODO(haraken): Implement correct lifetime using traceWrapper. |
| 185 ExecutionContext* context = | 185 ExecutionContext* context = |
| 186 toExecutionContext(wrapper->CreationContext()); | 186 toExecutionContext(wrapper->CreationContext()); |
| 187 if (context && !context->activeDOMObjectsAreStopped()) { | 187 if (context && !context->isContextDestroyed()) { |
| 188 m_isolate->SetObjectGroupId(*value, liveRootId()); | 188 m_isolate->SetObjectGroupId(*value, liveRootId()); |
| 189 ++m_domObjectsWithPendingActivity; | 189 ++m_domObjectsWithPendingActivity; |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 | 192 |
| 193 if (classId == WrapperTypeInfo::NodeClassId) { | 193 if (classId == WrapperTypeInfo::NodeClassId) { |
| 194 DCHECK(V8Node::hasInstance(wrapper, m_isolate)); | 194 DCHECK(V8Node::hasInstance(wrapper, m_isolate)); |
| 195 Node* node = V8Node::toImpl(wrapper); | 195 Node* node = V8Node::toImpl(wrapper); |
| 196 if (node->hasEventListeners()) | 196 if (node->hasEventListeners()) |
| 197 addReferencesForNodeWithEventListeners( | 197 addReferencesForNodeWithEventListeners( |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New( | 510 v8::Local<v8::Object> wrapper = v8::Local<v8::Object>::New( |
| 511 m_isolate, v8::Persistent<v8::Object>::Cast(*value)); | 511 m_isolate, v8::Persistent<v8::Object>::Cast(*value)); |
| 512 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); | 512 ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper)); |
| 513 // The ExecutionContext check is heavy, so it should be done at the last. | 513 // The ExecutionContext check is heavy, so it should be done at the last. |
| 514 if (toWrapperTypeInfo(wrapper)->isActiveScriptWrappable() && | 514 if (toWrapperTypeInfo(wrapper)->isActiveScriptWrappable() && |
| 515 toScriptWrappable(wrapper)->hasPendingActivity()) { | 515 toScriptWrappable(wrapper)->hasPendingActivity()) { |
| 516 // See the comment in MajorGCWrapperVisitor::VisitPersistentHandle. | 516 // See the comment in MajorGCWrapperVisitor::VisitPersistentHandle. |
| 517 ExecutionContext* context = | 517 ExecutionContext* context = |
| 518 toExecutionContext(wrapper->CreationContext()); | 518 toExecutionContext(wrapper->CreationContext()); |
| 519 if (context == m_executionContext && context && | 519 if (context == m_executionContext && context && |
| 520 !context->activeDOMObjectsAreStopped()) | 520 !context->isContextDestroyed()) |
| 521 m_pendingActivityFound = true; | 521 m_pendingActivityFound = true; |
| 522 } | 522 } |
| 523 } | 523 } |
| 524 | 524 |
| 525 bool pendingActivityFound() const { return m_pendingActivityFound; } | 525 bool pendingActivityFound() const { return m_pendingActivityFound; } |
| 526 | 526 |
| 527 private: | 527 private: |
| 528 v8::Isolate* m_isolate; | 528 v8::Isolate* m_isolate; |
| 529 Persistent<ExecutionContext> m_executionContext; | 529 Persistent<ExecutionContext> m_executionContext; |
| 530 bool m_pendingActivityFound; | 530 bool m_pendingActivityFound; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 543 double startTime = WTF::currentTimeMS(); | 543 double startTime = WTF::currentTimeMS(); |
| 544 v8::HandleScope scope(isolate); | 544 v8::HandleScope scope(isolate); |
| 545 PendingActivityVisitor visitor(isolate, executionContext); | 545 PendingActivityVisitor visitor(isolate, executionContext); |
| 546 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); | 546 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); |
| 547 scanPendingActivityHistogram.count( | 547 scanPendingActivityHistogram.count( |
| 548 static_cast<int>(WTF::currentTimeMS() - startTime)); | 548 static_cast<int>(WTF::currentTimeMS() - startTime)); |
| 549 return visitor.pendingActivityFound(); | 549 return visitor.pendingActivityFound(); |
| 550 } | 550 } |
| 551 | 551 |
| 552 } // namespace blink | 552 } // namespace blink |
| OLD | NEW |