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

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

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.h
diff --git a/chrome/browser/renderer_host/test_navigation_listener.h b/chrome/browser/renderer_host/test_navigation_listener.h
new file mode 100644
index 0000000000000000000000000000000000000000..0b1afece03dcb55a2905009d99ff12587eee11b9
--- /dev/null
+++ b/chrome/browser/renderer_host/test_navigation_listener.h
@@ -0,0 +1,58 @@
+// 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.
+
+#ifndef CHROME_BROWSER_RENDERER_HOST_TEST_NAVIGATION_LISTENER_H_
+#define CHROME_BROWSER_RENDERER_HOST_TEST_NAVIGATION_LISTENER_H_
+
+#include <list>
+#include <set>
+
+#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "webkit/glue/resource_type.h"
+
+class GURL;
+
+namespace content {
+class ResourceThrottle;
+}
+
+// This class can defer requests for arbitrary URLs. It's mainly intended for
+// testing.
+class TestNavigationListener
+ : public base::RefCountedThreadSafe<TestNavigationListener> {
+ public:
+ TestNavigationListener();
+ virtual ~TestNavigationListener();
+
+ // Add |url| to the set of URLs we should delay.
+ void DelayRequestsForURL(const GURL& url);
+
+ // Resume all deferred requests.
+ void ResumeAll();
+
+ // Constructs a ResourceThrottle if the request for |url| should be held.
+ //
+ // Needs to be invoked on the IO thread.
+ content::ResourceThrottle* CreateResourceThrottle(
+ const GURL& url,
+ ResourceType::Type resource_type);
+
+ private:
+ friend class base::RefCountedThreadSafe<TestNavigationListener>;
+
+ // Stores a throttle per URL request that we have delayed.
+ class Throttle;
+ typedef base::WeakPtr<Throttle> WeakThrottle;
+ typedef std::list<WeakThrottle> WeakThrottleList;
+ WeakThrottleList throttles_;
+
+ // The set of URLs to be delayed.
+ std::set<GURL> urls_to_delay_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestNavigationListener);
+};
+
+#endif // CHROME_BROWSER_RENDERER_HOST_TEST_NAVIGATION_LISTENER_H_

Powered by Google App Engine
This is Rietveld 408576698