OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/frame/DOMWindow.h" | 6 #include "core/frame/DOMWindow.h" |
7 | 7 |
8 #include "bindings/core/v8/ScriptCallStackFactory.h" | 8 #include "bindings/core/v8/ScriptCallStackFactory.h" |
9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
11 #include "core/dom/ExecutionContext.h" | 11 #include "core/dom/ExecutionContext.h" |
12 #include "core/dom/SecurityContext.h" | 12 #include "core/dom/SecurityContext.h" |
13 #include "core/events/MessageEvent.h" | 13 #include "core/events/MessageEvent.h" |
14 #include "core/frame/Frame.h" | 14 #include "core/frame/Frame.h" |
15 #include "core/frame/FrameClient.h" | 15 #include "core/frame/FrameClient.h" |
16 #include "core/frame/FrameConsole.h" | 16 #include "core/frame/FrameConsole.h" |
17 #include "core/frame/LocalDOMWindow.h" | 17 #include "core/frame/LocalDOMWindow.h" |
18 #include "core/frame/Location.h" | 18 #include "core/frame/Location.h" |
19 #include "core/frame/Settings.h" | 19 #include "core/frame/Settings.h" |
20 #include "core/frame/UseCounter.h" | 20 #include "core/frame/UseCounter.h" |
21 #include "core/inspector/ConsoleMessageStorage.h" | 21 #include "core/inspector/ConsoleMessageStorage.h" |
22 #include "core/inspector/InspectorInstrumentation.h" | 22 #include "core/inspector/InspectorInstrumentation.h" |
23 #include "core/inspector/ScriptCallStack.h" | 23 #include "core/inspector/ScriptCallStack.h" |
24 #include "core/loader/FrameLoaderClient.h" | 24 #include "core/loader/FrameLoaderClient.h" |
25 #include "core/loader/MixedContentChecker.h" | 25 #include "core/loader/MixedContentChecker.h" |
26 #include "core/page/ChromeClient.h" | 26 #include "core/page/ChromeClient.h" |
27 #include "core/page/Page.h" | 27 #include "core/page/Page.h" |
| 28 #include "platform/MemoryPurgeController.h" |
28 #include "platform/weborigin/KURL.h" | 29 #include "platform/weborigin/KURL.h" |
29 #include "platform/weborigin/SecurityOrigin.h" | 30 #include "platform/weborigin/SecurityOrigin.h" |
30 | 31 |
31 namespace blink { | 32 namespace blink { |
32 | 33 |
33 DOMWindow::DOMWindow() | 34 DOMWindow::DOMWindow() |
34 : m_windowIsClosing(false) | 35 : m_windowIsClosing(false) |
35 { | 36 { |
36 } | 37 } |
37 | 38 |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 | 335 |
335 page->chromeClient().closeWindowSoon(); | 336 page->chromeClient().closeWindowSoon(); |
336 | 337 |
337 // So as to make window.closed return the expected result | 338 // So as to make window.closed return the expected result |
338 // after window.close(), separately record the to-be-closed | 339 // after window.close(), separately record the to-be-closed |
339 // state of this window. Scripts may access window.closed | 340 // state of this window. Scripts may access window.closed |
340 // before the deferred close operation has gone ahead. | 341 // before the deferred close operation has gone ahead. |
341 m_windowIsClosing = true; | 342 m_windowIsClosing = true; |
342 } | 343 } |
343 | 344 |
| 345 void DOMWindow::purgeMemory(ExceptionState& exceptionState) |
| 346 { |
| 347 Document* currentDocument = document(); |
| 348 if (!currentDocument || !currentDocument->page()) { |
| 349 exceptionState.throwDOMException(InvalidAccessError, currentDocument ? "
The document's page cannot be retrieved." : "No context document can be obtained
."); |
| 350 return; |
| 351 } |
| 352 MemoryPurgeController& controller = currentDocument->page()->memoryPurgeCont
roller(); |
| 353 controller.purgeMemory(MemoryPurgeMode::NotSpecified); |
| 354 } |
| 355 |
344 DEFINE_TRACE(DOMWindow) | 356 DEFINE_TRACE(DOMWindow) |
345 { | 357 { |
346 visitor->trace(m_location); | 358 visitor->trace(m_location); |
347 EventTargetWithInlineData::trace(visitor); | 359 EventTargetWithInlineData::trace(visitor); |
348 } | 360 } |
349 | 361 |
350 } // namespace blink | 362 } // namespace blink |
OLD | NEW |