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

Unified Diff: content/test/test_render_frame.cc

Issue 2821473002: Service CreateNewWindow on the UI thread with a new mojo interface (Closed)
Patch Set: MakeShared goodness Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/test/test_render_frame.h ('k') | content/test/test_web_contents.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/test_render_frame.cc
diff --git a/content/test/test_render_frame.cc b/content/test/test_render_frame.cc
index 6c0bb0133b81b4af5f5e4e615a24e6bb8f48f943..3ae3715cd7cd14e106b25aa520611186ec60014e 100644
--- a/content/test/test_render_frame.cc
+++ b/content/test/test_render_frame.cc
@@ -4,14 +4,42 @@
#include "content/test/test_render_frame.h"
+#include "base/memory/ptr_util.h"
#include "content/common/navigation_params.h"
#include "content/common/resource_request_body_impl.h"
+#include "content/public/common/associated_interface_provider.h"
#include "content/public/common/browser_side_navigation_policy.h"
#include "content/public/common/resource_response.h"
+#include "content/public/test/mock_render_thread.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
namespace content {
+class MockFrameHost : public mojom::FrameHost {
+ public:
+ MockFrameHost() : binding_(this) {}
+ ~MockFrameHost() override = default;
+
+ void CreateNewWindow(mojom::CreateNewWindowParamsPtr params,
+ const CreateNewWindowCallback& callback) override {
+ mojom::CreateNewWindowReplyPtr reply = mojom::CreateNewWindowReply::New();
+ MockRenderThread* mock_render_thread =
+ static_cast<MockRenderThread*>(RenderThread::Get());
+ mock_render_thread->OnCreateWindow(*params, reply.get());
+ callback.Run(std::move(reply));
+ }
+
+ void Bind(mojo::ScopedInterfaceEndpointHandle handle) {
+ binding_.Bind(
+ mojo::MakeAssociatedRequest<mojom::FrameHost>(std::move(handle)));
+ }
+
+ private:
+ mojo::AssociatedBinding<mojom::FrameHost> binding_;
+
+ DISALLOW_COPY_AND_ASSIGN(MockFrameHost);
+};
+
// static
RenderFrameImpl* TestRenderFrame::CreateTestRenderFrame(
const RenderFrameImpl::CreateParams& params) {
@@ -19,7 +47,12 @@ RenderFrameImpl* TestRenderFrame::CreateTestRenderFrame(
}
TestRenderFrame::TestRenderFrame(const RenderFrameImpl::CreateParams& params)
- : RenderFrameImpl(params) {
+ : RenderFrameImpl(params),
+ mock_frame_host_(base::MakeUnique<MockFrameHost>()) {
+ GetRemoteAssociatedInterfaces()->OverrideBinderForTesting(
+ mojom::FrameHost::Name_,
+ base::Bind(&MockFrameHost::Bind,
+ base::Unretained(mock_frame_host_.get())));
}
TestRenderFrame::~TestRenderFrame() {
@@ -89,4 +122,12 @@ blink::WebNavigationPolicy TestRenderFrame::DecidePolicyForNavigation(
return RenderFrameImpl::DecidePolicyForNavigation(info);
}
+mojom::FrameHostAssociatedPtr TestRenderFrame::GetFrameHost() {
+ mojom::FrameHostAssociatedPtr ptr = RenderFrameImpl::GetFrameHost();
+
+ // Needed to ensure no deadlocks when waiting for sync IPC.
+ ptr.FlushForTesting();
Ken Rockot(use gerrit already) 2017/05/31 23:58:02 Can you please remind me exactly why this flush wa
Charlie Harrison 2017/06/01 01:35:12 Hey Ken, agreed this is not ideal especially if it
+ return ptr;
+}
+
} // namespace content
« no previous file with comments | « content/test/test_render_frame.h ('k') | content/test/test_web_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698