Update mojo surfaces bindings and mojo/cc/ glue
[chromium-blink-merge.git] / chrome / browser / prerender / prerender_pending_swap_throttle.h
blobebc3e1a38fb25db879d6afbd6226ad12ffac8093
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_PENDING_SWAP_THROTTLE_H_
6 #define CHROME_BROWSER_PRERENDER_PRERENDER_PENDING_SWAP_THROTTLE_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/weak_ptr.h"
11 #include "content/public/browser/resource_throttle.h"
13 namespace net {
14 class URLRequest;
17 namespace prerender {
19 class PrerenderTracker;
21 // This class implements policy on main frame navigations for prerenders
22 // which we would like to swap, but are pending session storage namespace
23 // merges. If the merge failed, we will release the throttle. If the merge
24 // succeeded, we will swap the prerender, making the underlying request
25 // obsolete.
26 class PrerenderPendingSwapThrottle
27 : public content::ResourceThrottle,
28 public base::SupportsWeakPtr<PrerenderPendingSwapThrottle> {
29 public:
30 PrerenderPendingSwapThrottle(net::URLRequest* request,
31 PrerenderTracker* tracker);
33 // content::ResourceThrottle implementation:
34 virtual void WillStartRequest(bool* defer) OVERRIDE;
36 virtual const char* GetNameForLogging() const OVERRIDE;
38 // Called by the PrerenderTracker when the swap failed.
39 // May only be called if currently throttling the resource.
40 void Resume();
42 // Called by the PrerenderTracker when the swap succeeded.
43 // May only be called if currently throttling the resource.
44 void Cancel();
46 private:
47 net::URLRequest* request_;
48 PrerenderTracker* tracker_;
49 bool throttled_;
51 DISALLOW_COPY_AND_ASSIGN(PrerenderPendingSwapThrottle);
54 } // namespace prerender
56 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_PENDING_SWAP_THROTTLE_H_