summaryrefslogtreecommitdiffstats
path: root/extensions/renderer/scoped_web_frame.h
diff options
context:
space:
mode:
authorharaken <haraken@chromium.org>2015-06-25 19:03:07 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-26 02:03:35 +0000
commit1156707553435bdc1a7830186e38f0e5dc01f8f4 (patch)
treeb6ead5fac6d0282071de62afd4cab52390d5dd11 /extensions/renderer/scoped_web_frame.h
parenteae6808489d37aaeede466164d89ce3ecb65d8bd (diff)
downloadchromium_src-1156707553435bdc1a7830186e38f0e5dc01f8f4.zip
chromium_src-1156707553435bdc1a7830186e38f0e5dc01f8f4.tar.gz
chromium_src-1156707553435bdc1a7830186e38f0e5dc01f8f4.tar.bz2
ScriptContextSetTest should close the main frame before finishing the test
ScriptContextSetTest should close the main frame and the webview, and then collect garbage in Oilpan's heap before finishing the test. Otherwise, the resources retained by the main frame are reported as leaking on LSan builds. BUG=497658 Review URL: https://codereview.chromium.org/1210513002 Cr-Commit-Position: refs/heads/master@{#336321}
Diffstat (limited to 'extensions/renderer/scoped_web_frame.h')
-rw-r--r--extensions/renderer/scoped_web_frame.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/extensions/renderer/scoped_web_frame.h b/extensions/renderer/scoped_web_frame.h
new file mode 100644
index 0000000..7950552
--- /dev/null
+++ b/extensions/renderer/scoped_web_frame.h
@@ -0,0 +1,33 @@
+// Copyright 2015 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.
+
+#ifndef SCOPED_WEB_FRAME_H_
+#define SCOPED_WEB_FRAME_H_
+
+#include "third_party/WebKit/public/web/WebLocalFrame.h"
+#include "third_party/WebKit/public/web/WebView.h"
+
+namespace extensions {
+
+// ScopedWebFrame is a class to create a dummy webview and frame for testing.
+// The dymmy webview and frame will be destructed when the scope exits.
+class ScopedWebFrame {
+public:
+ ScopedWebFrame();
+ ~ScopedWebFrame();
+
+ blink::WebLocalFrame* frame() { return frame_; }
+
+private:
+ // The webview and the frame are kept alive by the ScopedWebFrame
+ // because they are not destructed unless ~ScopedWebFrame explicitly
+ // closes the webview and the frame.
+ blink::WebView* view_;
+ blink::WebLocalFrame* frame_;
+ DISALLOW_COPY_AND_ASSIGN(ScopedWebFrame);
+};
+
+} // namespace extensions
+
+#endif // SCOPED_WEB_FRAME_H_