Index: Source/core/frame/FrameProtector.cpp |
diff --git a/Source/core/frame/FrameProtector.cpp b/Source/core/frame/FrameProtector.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c7ffc5f80e89784820829b86c38ed214d7ea5174 |
--- /dev/null |
+++ b/Source/core/frame/FrameProtector.cpp |
@@ -0,0 +1,61 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+#include "core/frame/FrameProtector.h" |
+ |
+#include "core/frame/Frame.h" |
+#include "core/frame/FrameView.h" |
+#include "core/frame/LocalFrame.h" |
+ |
+namespace blink { |
+ |
+ |
+FrameProtector::FrameProtector(PassRefPtrWillBeRawPtr<Frame> frame) |
+ : m_frame(frame) |
+#if ENABLE(OILPAN) |
+ , m_isActive(m_frame && !m_frame->hasBeenDisposed()) |
+#endif |
+{ |
+#if ENABLE(OILPAN) |
+ if (m_isActive) |
+ m_frame->incrementDisposeProtectionCount(); |
+#endif |
+} |
+ |
+FrameProtector::~FrameProtector() |
+{ |
+#if ENABLE(OILPAN) |
+ if (willDispose()) |
+ m_frame->dispose(); |
+#endif |
+} |
+ |
+bool FrameProtector::willDispose() const |
+{ |
+#if ENABLE(OILPAN) |
+ return m_isActive && m_frame->decrementDisposeProtectionCount() == 0 && m_frame->hasBeenDisposed(); |
+#else |
+ return m_frame && m_frame->hasOneRef(); |
+#endif |
+} |
+ |
+FrameViewProtector::FrameViewProtector(PassRefPtr<FrameView> frameView) |
+ : m_frameView(frameView) |
+#if ENABLE(OILPAN) |
+ , m_frameProtector(m_frameView ? &m_frameView->frame() : nullptr) |
+#endif |
+{ |
+} |
+ |
+bool FrameViewProtector::willDelete() const |
+{ |
+ return m_frameView && m_frameView->hasOneRef(); |
+} |
+ |
+FrameViewProtector::~FrameViewProtector() |
+{ |
+} |
+ |
+} // namespace blink |