OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 : m_client(client) | 58 : m_client(client) |
59 , m_delayedGCAndReportTimer(this, &WebLeakDetectorImpl::delayedGCAndRepo
rt) | 59 , m_delayedGCAndReportTimer(this, &WebLeakDetectorImpl::delayedGCAndRepo
rt) |
60 , m_delayedReportTimer(this, &WebLeakDetectorImpl::delayedReport) | 60 , m_delayedReportTimer(this, &WebLeakDetectorImpl::delayedReport) |
61 , m_numberOfGCNeeded(0) | 61 , m_numberOfGCNeeded(0) |
62 { | 62 { |
63 ASSERT(m_client); | 63 ASSERT(m_client); |
64 } | 64 } |
65 | 65 |
66 ~WebLeakDetectorImpl() override {} | 66 ~WebLeakDetectorImpl() override {} |
67 | 67 |
68 void collectGarbageAndGetDOMCounts(WebLocalFrame*) override; | 68 void prepareForLeakDetection(WebLocalFrame*) override; |
| 69 void collectGarbageAndReport() override; |
69 | 70 |
70 private: | 71 private: |
71 void delayedGCAndReport(Timer<WebLeakDetectorImpl>*); | 72 void delayedGCAndReport(Timer<WebLeakDetectorImpl>*); |
72 void delayedReport(Timer<WebLeakDetectorImpl>*); | 73 void delayedReport(Timer<WebLeakDetectorImpl>*); |
73 | 74 |
74 WebLeakDetectorClient* m_client; | 75 WebLeakDetectorClient* m_client; |
75 Timer<WebLeakDetectorImpl> m_delayedGCAndReportTimer; | 76 Timer<WebLeakDetectorImpl> m_delayedGCAndReportTimer; |
76 Timer<WebLeakDetectorImpl> m_delayedReportTimer; | 77 Timer<WebLeakDetectorImpl> m_delayedReportTimer; |
77 int m_numberOfGCNeeded; | 78 int m_numberOfGCNeeded; |
78 }; | 79 }; |
79 | 80 |
80 void WebLeakDetectorImpl::collectGarbageAndGetDOMCounts(WebLocalFrame* frame) | 81 void WebLeakDetectorImpl::prepareForLeakDetection(WebLocalFrame* frame) |
81 { | 82 { |
82 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 83 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
83 v8::HandleScope handleScope(isolate); | 84 v8::HandleScope handleScope(isolate); |
84 | 85 |
85 // For example, calling isValidEmailAddress in EmailInputType.cpp with a | 86 // For example, calling isValidEmailAddress in EmailInputType.cpp with a |
86 // non-empty string creates a static ScriptRegexp value which holds a | 87 // non-empty string creates a static ScriptRegexp value which holds a |
87 // V8PerContextData indirectly. This affects the number of V8PerContextData. | 88 // V8PerContextData indirectly. This affects the number of V8PerContextData. |
88 // To ensure that context data is created, call ensureScriptRegexpContext | 89 // To ensure that context data is created, call ensureScriptRegexpContext |
89 // here. | 90 // here. |
90 V8PerIsolateData::from(isolate)->ensureScriptRegexpContext(); | 91 V8PerIsolateData::from(isolate)->ensureScriptRegexpContext(); |
91 | 92 |
92 WorkerThread::terminateAndWaitForAllWorkers(); | 93 WorkerThread::terminateAndWaitForAllWorkers(); |
93 memoryCache()->evictResources(); | 94 memoryCache()->evictResources(); |
94 | 95 |
95 { | 96 { |
96 RefPtrWillBeRawPtr<Document> document = PassRefPtrWillBeRawPtr<Document>
(frame->document()); | 97 RefPtrWillBeRawPtr<Document> document = PassRefPtrWillBeRawPtr<Document>
(frame->document()); |
97 if (ResourceFetcher* fetcher = document->fetcher()) | 98 if (ResourceFetcher* fetcher = document->fetcher()) |
98 fetcher->garbageCollectDocumentResources(); | 99 fetcher->garbageCollectDocumentResources(); |
99 } | 100 } |
100 | 101 |
101 // FIXME: HTML5 Notification should be closed because notification affects t
he result of number of DOM objects. | 102 // FIXME: HTML5 Notification should be closed because notification affects t
he result of number of DOM objects. |
102 | 103 |
103 V8GCController::collectAllGarbageForTesting(isolate); | 104 V8PerIsolateData::from(isolate)->clearScriptRegexpContext(); |
| 105 } |
| 106 |
| 107 void WebLeakDetectorImpl::collectGarbageAndReport() |
| 108 { |
| 109 V8GCController::collectAllGarbageForTesting(V8PerIsolateData::mainThreadIsol
ate()); |
104 // Note: Oilpan precise GC is scheduled at the end of the event loop. | 110 // Note: Oilpan precise GC is scheduled at the end of the event loop. |
105 | 111 |
106 V8PerIsolateData::from(isolate)->clearScriptRegexpContext(); | |
107 | |
108 // Task queue may contain delayed object destruction tasks. | 112 // Task queue may contain delayed object destruction tasks. |
109 // This method is called from navigation hook inside FrameLoader, | 113 // This method is called from navigation hook inside FrameLoader, |
110 // so previous document is still held by the loader until the next event loo
p. | 114 // so previous document is still held by the loader until the next event loo
p. |
111 // Complete all pending tasks before proceeding to gc. | 115 // Complete all pending tasks before proceeding to gc. |
112 m_numberOfGCNeeded = 2; | 116 m_numberOfGCNeeded = 2; |
113 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); | 117 m_delayedGCAndReportTimer.startOneShot(0, BLINK_FROM_HERE); |
114 } | 118 } |
115 | 119 |
116 void WebLeakDetectorImpl::delayedGCAndReport(Timer<WebLeakDetectorImpl>*) | 120 void WebLeakDetectorImpl::delayedGCAndReport(Timer<WebLeakDetectorImpl>*) |
117 { | 121 { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 156 } |
153 | 157 |
154 } // namespace | 158 } // namespace |
155 | 159 |
156 WebLeakDetector* WebLeakDetector::create(WebLeakDetectorClient* client) | 160 WebLeakDetector* WebLeakDetector::create(WebLeakDetectorClient* client) |
157 { | 161 { |
158 return new WebLeakDetectorImpl(client); | 162 return new WebLeakDetectorImpl(client); |
159 } | 163 } |
160 | 164 |
161 } // namespace blink | 165 } // namespace blink |
OLD | NEW |