Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(644)

Side by Side Diff: Source/web/WebLocalFrameImpl.cpp

Issue 517043003: Move Frame to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Back out non-Oilpan experiment + tidy up by adding frame() ref accessors Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // || 42 // ||
43 // || 43 // ||
44 // FrameLoader 44 // FrameLoader
45 // 45 //
46 // FrameLoader and LocalFrame are formerly one object that was split apart becau se 46 // FrameLoader and LocalFrame are formerly one object that was split apart becau se
47 // it got too big. They basically have the same lifetime, hence the double line. 47 // it got too big. They basically have the same lifetime, hence the double line.
48 // 48 //
49 // From the perspective of the embedder, WebFrame is simply an object that it 49 // From the perspective of the embedder, WebFrame is simply an object that it
50 // allocates by calling WebFrame::create() and must be freed by calling close(). 50 // allocates by calling WebFrame::create() and must be freed by calling close().
51 // Internally, WebFrame is actually refcounted and it holds a reference to its 51 // Internally, WebFrame is actually refcounted and it holds a reference to its
52 // corresponding LocalFrame in WebCore. 52 // corresponding LocalFrame in blink.
53 //
54 // Oilpan: the middle objects + Page in the above diagram are Oilpan heap alloca ted,
55 // WebView and FrameView are currently not. In terms of ownership and control, t he
56 // relationships stays the same, but the references from the off-heap WebView to the
57 // on-heap Page is handled by a Persistent<>, not a RefPtr<>. Similarly, the mut ual
58 // strong references between the on-heap LocalFrame and the off-heap FrameView
59 // is through a RefPtr (from LocalFrame to FrameView), and a Persistent refers
60 // to the LocalFrame in the other direction.
61 //
62 // From the embedder's point of view, the use of Oilpan brings no changes. close ()
63 // must still be used to signal that the embedder is through with the WebFrame.
64 // Calling it will bring about the release and finalization of the frame object,
65 // and everything underneath.
53 // 66 //
54 // How frames are destroyed 67 // How frames are destroyed
55 // ------------------------ 68 // ------------------------
56 // 69 //
57 // The main frame is never destroyed and is re-used. The FrameLoader is re-used 70 // The main frame is never destroyed and is re-used. The FrameLoader is re-used
58 // and a reference to the main frame is kept by the Page. 71 // and a reference to the main frame is kept by the Page.
59 // 72 //
60 // When frame content is replaced, all subframes are destroyed. This happens 73 // When frame content is replaced, all subframes are destroyed. This happens
61 // in FrameLoader::detachFromParent for each subframe in a pre-order depth-first 74 // in FrameLoader::detachFromParent for each subframe in a pre-order depth-first
62 // traversal. Note that child node order may not match DOM node order! 75 // traversal. Note that child node order may not match DOM node order!
63 // detachFromParent() calls FrameLoaderClient::detachedFromParent(), which calls 76 // detachFromParent() calls FrameLoaderClient::detachedFromParent(), which calls
64 // WebFrame::frameDetached(). This triggers WebFrame to clear its reference to 77 // WebFrame::frameDetached(). This triggers WebFrame to clear its reference to
65 // LocalFrame, and also notifies the embedder via WebFrameClient that the frame is 78 // LocalFrame, and also notifies the embedder via WebFrameClient that the frame is
66 // detached. Most embedders will invoke close() on the WebFrame at this point, 79 // detached. Most embedders will invoke close() on the WebFrame at this point,
67 // triggering its deletion unless something else is still retaining a reference. 80 // triggering its deletion unless something else is still retaining a reference.
68 // 81 //
69 // Thie client is expected to be set whenever the WebLocalFrameImpl is attached to 82 // The client is expected to be set whenever the WebLocalFrameImpl is attached t o
70 // the DOM. 83 // the DOM.
71 84
72 #include "config.h" 85 #include "config.h"
73 #include "web/WebLocalFrameImpl.h" 86 #include "web/WebLocalFrameImpl.h"
74 87
75 #include "bindings/core/v8/DOMWrapperWorld.h" 88 #include "bindings/core/v8/DOMWrapperWorld.h"
76 #include "bindings/core/v8/ExceptionState.h" 89 #include "bindings/core/v8/ExceptionState.h"
77 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 90 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
78 #include "bindings/core/v8/ScriptController.h" 91 #include "bindings/core/v8/ScriptController.h"
79 #include "bindings/core/v8/ScriptSourceCode.h" 92 #include "bindings/core/v8/ScriptSourceCode.h"
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 WebRemoteFrame* WebLocalFrameImpl::toWebRemoteFrame() 504 WebRemoteFrame* WebLocalFrameImpl::toWebRemoteFrame()
492 { 505 {
493 ASSERT_NOT_REACHED(); 506 ASSERT_NOT_REACHED();
494 return 0; 507 return 0;
495 } 508 }
496 509
497 void WebLocalFrameImpl::close() 510 void WebLocalFrameImpl::close()
498 { 511 {
499 m_client = 0; 512 m_client = 0;
500 513
514 #if ENABLE(OILPAN)
515 m_selfKeepAlive.clear();
516 #else
501 deref(); // Balances ref() acquired in WebFrame::create 517 deref(); // Balances ref() acquired in WebFrame::create
518 #endif
502 } 519 }
503 520
504 WebString WebLocalFrameImpl::uniqueName() const 521 WebString WebLocalFrameImpl::uniqueName() const
505 { 522 {
506 return frame()->tree().uniqueName(); 523 return frame()->tree().uniqueName();
507 } 524 }
508 525
509 WebString WebLocalFrameImpl::assignedName() const 526 WebString WebLocalFrameImpl::assignedName() const
510 { 527 {
511 return frame()->tree().name(); 528 return frame()->tree().name();
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 1537
1521 // WebLocalFrameImpl public ---------------------------------------------------- ----- 1538 // WebLocalFrameImpl public ---------------------------------------------------- -----
1522 1539
1523 WebLocalFrame* WebLocalFrame::create(WebFrameClient* client) 1540 WebLocalFrame* WebLocalFrame::create(WebFrameClient* client)
1524 { 1541 {
1525 return WebLocalFrameImpl::create(client); 1542 return WebLocalFrameImpl::create(client);
1526 } 1543 }
1527 1544
1528 WebLocalFrameImpl* WebLocalFrameImpl::create(WebFrameClient* client) 1545 WebLocalFrameImpl* WebLocalFrameImpl::create(WebFrameClient* client)
1529 { 1546 {
1530 return adoptRef(new WebLocalFrameImpl(client)).leakRef(); 1547 WebLocalFrameImpl* frame = new WebLocalFrameImpl(client);
1548 #if ENABLE(OILPAN)
1549 return frame;
1550 #else
1551 return adoptRef(frame).leakRef();
1552 #endif
1531 } 1553 }
1532 1554
1533 WebLocalFrameImpl::WebLocalFrameImpl(WebFrameClient* client) 1555 WebLocalFrameImpl::WebLocalFrameImpl(WebFrameClient* client)
1534 : m_frameLoaderClientImpl(this) 1556 : m_frameLoaderClientImpl(this)
1535 , m_client(client) 1557 , m_client(client)
1536 , m_permissionClient(0) 1558 , m_permissionClient(0)
1537 , m_inputEventsScaleFactorForEmulation(1) 1559 , m_inputEventsScaleFactorForEmulation(1)
1538 , m_userMediaClientImpl(this) 1560 , m_userMediaClientImpl(this)
1539 , m_geolocationClientProxy(GeolocationClientProxy::create(client ? client->g eolocationClient() : 0)) 1561 , m_geolocationClientProxy(GeolocationClientProxy::create(client ? client->g eolocationClient() : 0))
1562 #if ENABLE(OILPAN)
1563 , m_selfKeepAlive(this)
1564 #endif
1540 { 1565 {
1541 Platform::current()->incrementStatsCounter(webFrameActiveCount); 1566 Platform::current()->incrementStatsCounter(webFrameActiveCount);
1542 frameCount++; 1567 frameCount++;
1543 } 1568 }
1544 1569
1545 WebLocalFrameImpl::~WebLocalFrameImpl() 1570 WebLocalFrameImpl::~WebLocalFrameImpl()
1546 { 1571 {
1547 Platform::current()->decrementStatsCounter(webFrameActiveCount); 1572 Platform::current()->decrementStatsCounter(webFrameActiveCount);
1548 frameCount--; 1573 frameCount--;
1549 1574
1550 cancelPendingScopingEffort(); 1575 cancelPendingScopingEffort();
1551 } 1576 }
1552 1577
1553 void WebLocalFrameImpl::setCoreFrame(PassRefPtr<LocalFrame> frame) 1578 void WebLocalFrameImpl::trace(Visitor* visitor)
1579 {
1580 #if ENABLE(OILPAN)
1581 visitor->trace(m_frame);
1582 visitor->trace(m_printContext);
1583 visitor->trace(m_geolocationClientProxy);
1584
1585 WebFrame::traceChildren(visitor, this);
1586 #endif
1587 }
1588
1589 void WebLocalFrameImpl::setCoreFrame(PassRefPtrWillBeRawPtr<LocalFrame> frame)
1554 { 1590 {
1555 m_frame = frame; 1591 m_frame = frame;
1556 1592
1557 // FIXME: we shouldn't add overhead to every frame by registering these obje cts when they're not used. 1593 // FIXME: we shouldn't add overhead to every frame by registering these obje cts when they're not used.
1558 if (m_frame) { 1594 if (m_frame) {
1559 OwnPtr<NotificationPresenterImpl> notificationPresenter = adoptPtr(new N otificationPresenterImpl()); 1595 OwnPtr<NotificationPresenterImpl> notificationPresenter = adoptPtr(new N otificationPresenterImpl());
1560 if (m_client) 1596 if (m_client)
1561 notificationPresenter->initialize(m_client->notificationPresenter()) ; 1597 notificationPresenter->initialize(m_client->notificationPresenter()) ;
1562 1598
1563 provideNotification(*m_frame, notificationPresenter.release()); 1599 provideNotification(*m_frame, notificationPresenter.release());
1564 provideNotificationPermissionClientTo(*m_frame, NotificationPermissionCl ientImpl::create()); 1600 provideNotificationPermissionClientTo(*m_frame, NotificationPermissionCl ientImpl::create());
1565 provideUserMediaTo(*m_frame, &m_userMediaClientImpl); 1601 provideUserMediaTo(*m_frame, &m_userMediaClientImpl);
1566 provideGeolocationTo(*m_frame, m_geolocationClientProxy.get()); 1602 provideGeolocationTo(*m_frame, m_geolocationClientProxy.get());
1567 m_geolocationClientProxy->setController(GeolocationController::from(m_fr ame.get())); 1603 m_geolocationClientProxy->setController(GeolocationController::from(m_fr ame.get()));
1568 provideMIDITo(*m_frame, MIDIClientProxy::create(m_client ? m_client->web MIDIClient() : 0)); 1604 provideMIDITo(*m_frame, MIDIClientProxy::create(m_client ? m_client->web MIDIClient() : 0));
1569 provideLocalFileSystemTo(*m_frame, LocalFileSystemClient::create()); 1605 provideLocalFileSystemTo(*m_frame, LocalFileSystemClient::create());
1570 1606
1571 if (RuntimeEnabledFeatures::screenOrientationEnabled()) 1607 if (RuntimeEnabledFeatures::screenOrientationEnabled())
1572 ScreenOrientationController::provideTo(*m_frame, m_client ? m_client ->webScreenOrientationClient() : 0); 1608 ScreenOrientationController::provideTo(*m_frame, m_client ? m_client ->webScreenOrientationClient() : 0);
1573 } 1609 }
1574 } 1610 }
1575 1611
1576 PassRefPtr<LocalFrame> WebLocalFrameImpl::initializeCoreFrame(FrameHost* host, F rameOwner* owner, const AtomicString& name, const AtomicString& fallbackName) 1612 PassRefPtrWillBeRawPtr<LocalFrame> WebLocalFrameImpl::initializeCoreFrame(FrameH ost* host, FrameOwner* owner, const AtomicString& name, const AtomicString& fall backName)
1577 { 1613 {
1578 RefPtr<LocalFrame> frame = LocalFrame::create(&m_frameLoaderClientImpl, host , owner); 1614 RefPtrWillBeRawPtr<LocalFrame> frame = LocalFrame::create(&m_frameLoaderClie ntImpl, host, owner);
1579 setCoreFrame(frame); 1615 setCoreFrame(frame);
1580 frame->tree().setName(name, fallbackName); 1616 frame->tree().setName(name, fallbackName);
1581 // We must call init() after m_frame is assigned because it is referenced 1617 // We must call init() after m_frame is assigned because it is referenced
1582 // during init(). Note that this may dispatch JS events; the frame may be 1618 // during init(). Note that this may dispatch JS events; the frame may be
1583 // detached after init() returns. 1619 // detached after init() returns.
1584 frame->init(); 1620 frame->init();
1585 return frame; 1621 return frame;
1586 } 1622 }
1587 1623
1588 PassRefPtr<LocalFrame> WebLocalFrameImpl::createChildFrame(const FrameLoadReques t& request, HTMLFrameOwnerElement* ownerElement) 1624 PassRefPtrWillBeRawPtr<LocalFrame> WebLocalFrameImpl::createChildFrame(const Fra meLoadRequest& request, HTMLFrameOwnerElement* ownerElement)
1589 { 1625 {
1590 ASSERT(m_client); 1626 ASSERT(m_client);
1591 WebLocalFrameImpl* webframeChild = toWebLocalFrameImpl(m_client->createChild Frame(this, request.frameName())); 1627 WebLocalFrameImpl* webframeChild = toWebLocalFrameImpl(m_client->createChild Frame(this, request.frameName()));
1592 if (!webframeChild) 1628 if (!webframeChild)
1593 return nullptr; 1629 return nullptr;
1594 1630
1595 // FIXME: Using subResourceAttributeName as fallback is not a perfect 1631 // FIXME: Using subResourceAttributeName as fallback is not a perfect
1596 // solution. subResourceAttributeName returns just one attribute name. The 1632 // solution. subResourceAttributeName returns just one attribute name. The
1597 // element might not have the attribute, and there might be other attributes 1633 // element might not have the attribute, and there might be other attributes
1598 // which can identify the element. 1634 // which can identify the element.
1599 RefPtr<LocalFrame> child = webframeChild->initializeCoreFrame(frame()->host( ), ownerElement, request.frameName(), ownerElement->getAttribute(ownerElement->s ubResourceAttributeName())); 1635 RefPtrWillBeRawPtr<LocalFrame> child = webframeChild->initializeCoreFrame(fr ame()->host(), ownerElement, request.frameName(), ownerElement->getAttribute(own erElement->subResourceAttributeName()));
1600 // Initializing the core frame may cause the new child to be detached, since 1636 // Initializing the core frame may cause the new child to be detached, since
1601 // it may dispatch a load event in the parent. 1637 // it may dispatch a load event in the parent.
1602 if (!child->tree().parent()) 1638 if (!child->tree().parent())
1603 return nullptr; 1639 return nullptr;
1604 1640
1605 // If we're moving in the back/forward list, we might want to replace the co ntent 1641 // If we're moving in the back/forward list, we might want to replace the co ntent
1606 // of this child frame with whatever was there at that point. 1642 // of this child frame with whatever was there at that point.
1607 RefPtr<HistoryItem> childItem; 1643 RefPtr<HistoryItem> childItem;
1608 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen t()->loadEventFinished()) 1644 if (isBackForwardLoadType(frame()->loader().loadType()) && !frame()->documen t()->loadEventFinished())
1609 childItem = PassRefPtr<HistoryItem>(webframeChild->client()->historyItem ForNewChildFrame(webframeChild)); 1645 childItem = PassRefPtr<HistoryItem>(webframeChild->client()->historyItem ForNewChildFrame(webframeChild));
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 1913
1878 void WebLocalFrameImpl::invalidateAll() const 1914 void WebLocalFrameImpl::invalidateAll() const
1879 { 1915 {
1880 ASSERT(frame() && frame()->view()); 1916 ASSERT(frame() && frame()->view());
1881 FrameView* view = frame()->view(); 1917 FrameView* view = frame()->view();
1882 view->invalidateRect(view->frameRect()); 1918 view->invalidateRect(view->frameRect());
1883 invalidateScrollbar(); 1919 invalidateScrollbar();
1884 } 1920 }
1885 1921
1886 } // namespace blink 1922 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698