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

Unified Diff: chrome/browser/renderer_host/test_navigation_listener.cc

Issue 10823169: Another attempt at fixing dead frames being tracked by webNavigation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 8 years, 4 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: chrome/browser/renderer_host/test_navigation_listener.cc
diff --git a/chrome/browser/renderer_host/test_navigation_listener.cc b/chrome/browser/renderer_host/test_navigation_listener.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b6e2f13850b901b930bd5fd0ea472451a82bab48
--- /dev/null
+++ b/chrome/browser/renderer_host/test_navigation_listener.cc
@@ -0,0 +1,69 @@
+// Copyright (c) 2012 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 "chrome/browser/renderer_host/test_navigation_listener.h"
+
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/resource_controller.h"
+#include "content/public/browser/resource_throttle.h"
+#include "googleurl/src/gurl.h"
+
+class TestNavigationListener::Throttle
+ : public content::ResourceThrottle,
+ public base::SupportsWeakPtr<TestNavigationListener::Throttle> {
+ public:
+ void Resume() {
+ controller()->Resume();
+ }
+
+ // content::ResourceThrottle implementation.
+ virtual void WillStartRequest(bool* defer) {
+ *defer = true;
+ }
+};
+
+TestNavigationListener::TestNavigationListener() {}
+
+TestNavigationListener::~TestNavigationListener() {}
+
+void TestNavigationListener::DelayRequestsForURL(const GURL& url)
+{
battre 2012/08/07 13:34:40 nit: { in previous line
+ if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) {
+ content::BrowserThread::PostTask(
+ content::BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&TestNavigationListener::DelayRequestsForURL, this, url));
+ return;
+ }
+ urls_to_delay_.insert(url);
+}
+
+void TestNavigationListener::ResumeAll()
+{
battre 2012/08/07 13:34:40 nit: { in previous line
+ if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) {
+ content::BrowserThread::PostTask(
+ content::BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&TestNavigationListener::ResumeAll, this));
+ return;
+ }
+ WeakThrottleList::const_iterator it;
+ for (it = throttles_.begin(); it != throttles_.end(); ++it) {
+ if (*it)
+ (*it)->Resume();
+ }
+ throttles_.clear();
+}
+
+content::ResourceThrottle* TestNavigationListener::CreateResourceThrottle(
+ const GURL& url,
+ ResourceType::Type resource_type) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ if (urls_to_delay_.find(url) == urls_to_delay_.end())
+ return NULL;
+
+ Throttle* throttle = new Throttle();
+ throttles_.push_back(throttle->AsWeakPtr());
+ return throttle;
+}

Powered by Google App Engine
This is Rietveld 408576698