| 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_
|
|
|