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

Unified Diff: content/test/test_frame_navigation_observer.cc

Issue 248963007: Perform navigation policy check on UI thread for --site-per-process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Some minor cleanup. Created 6 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
Index: content/test/test_frame_navigation_observer.cc
diff --git a/content/test/test_frame_navigation_observer.cc b/content/test/test_frame_navigation_observer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..65c6632100ed941ecaa2f9b8c642981c0b5e5b1a
--- /dev/null
+++ b/content/test/test_frame_navigation_observer.cc
@@ -0,0 +1,74 @@
+// 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 "content/test/test_frame_navigation_observer.h"
+
+#include "base/bind.h"
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
+#include "base/stl_util.h"
+#include "content/browser/frame_host/navigation_entry_impl.h"
+#include "content/browser/frame_host/render_frame_host_impl.h"
+#include "content/browser/renderer_host/render_view_host_impl.h"
+#include "content/browser/web_contents/web_contents_impl.h"
+#include "content/public/browser/web_contents_observer.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace content {
+
+TestFrameNavigationObserver::TestFrameNavigationObserver(
+ RenderFrameHostImpl* render_frame_host,
+ int number_of_navigations)
+ : WebContentsObserver(render_frame_host->delegate()->GetAsWebContents()),
+ render_frame_host_(render_frame_host),
+ navigation_started_(false),
+ navigations_completed_(0),
+ number_of_navigations_(number_of_navigations),
+ message_loop_runner_(new MessageLoopRunner) {
+}
+
+TestFrameNavigationObserver::TestFrameNavigationObserver(
+ RenderFrameHostImpl* render_frame_host)
+ : WebContentsObserver(render_frame_host->delegate()->GetAsWebContents()),
+ render_frame_host_(render_frame_host),
+ navigation_started_(false),
+ navigations_completed_(0),
+ number_of_navigations_(1),
+ message_loop_runner_(new MessageLoopRunner) {
+}
+
+TestFrameNavigationObserver::~TestFrameNavigationObserver() {
+}
+
+void TestFrameNavigationObserver::Wait() {
+ message_loop_runner_->Run();
+}
+
+void TestFrameNavigationObserver::DidStartProvisionalLoadForFrame(
+ int64 frame_id,
+ int64 parent_frame_id,
+ bool is_main_frame,
+ const GURL& validated_url,
+ bool is_error_page,
+ bool is_iframe_srcdoc,
+ RenderViewHost* render_view_host) {
+ if (frame_id == render_frame_host_->GetRoutingID()) {
Charlie Reis 2014/04/24 20:37:50 nit: No braces needed.
nasko 2014/04/24 22:31:12 Done.
+ navigation_started_ = true;
+ }
+}
+
+void TestFrameNavigationObserver::DidNavigateAnyFrame(
+ const LoadCommittedDetails& details,
+ const FrameNavigateParams& params) {
+ if (!navigation_started_)
+ return;
+
+ ++navigations_completed_;
+ if (navigations_completed_ == number_of_navigations_) {
+ navigation_started_ = false;
+ message_loop_runner_->Quit();
+ }
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698