OLD | NEW |
| (Empty) |
1 // Copyright 2014 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. | |
4 | |
5 #ifndef CHROME_RENDERER_NET_ERROR_CACHE_LOAD_H_ | |
6 #define CHROME_RENDERER_NET_ERROR_CACHE_LOAD_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "content/public/renderer/render_frame_observer.h" | |
10 #include "gin/wrappable.h" | |
11 #include "url/gurl.h" | |
12 | |
13 // ErrorCacheLoad class: | |
14 // | |
15 // This class makes cache loading operations available to the | |
16 // error page loaded by NetErrorHelper. It is bound to the javascript | |
17 // window.errorCacheLoad object. | |
18 | |
19 class GURL; | |
20 | |
21 namespace content { | |
22 class RenderFrame; | |
23 } | |
24 | |
25 class ErrorCacheLoad : public gin::Wrappable<ErrorCacheLoad>, | |
26 public content::RenderFrameObserver { | |
27 public: | |
28 static gin::WrapperInfo kWrapperInfo; | |
29 | |
30 static void Install(content::RenderFrame* render_frame, const GURL& page_url); | |
31 | |
32 private: | |
33 ErrorCacheLoad(content::RenderFrame* render_frame, const GURL& page_url); | |
34 virtual ~ErrorCacheLoad(); | |
35 | |
36 // Loads the original URL associated with the frame, with the blink | |
37 // ReturnCacheDataDontLoad flag set to make sure that the value is | |
38 // only gotten from cache. | |
39 bool ReloadStaleInstance(); | |
40 | |
41 // gin::WrappableBase | |
42 virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder( | |
43 v8::Isolate* isolate) OVERRIDE; | |
44 | |
45 // RenderFrameObserver. Overridden to avoid being destroyed when RenderFrame | |
46 // goes away; ErrorCacheLoad objects are owned by the JS garbage collector. | |
47 virtual void OnDestruct() OVERRIDE; | |
48 | |
49 // We'll be torn down by V8 when the page goes away, so it's safe to hold | |
50 // a naked pointer to the render frame. | |
51 content::RenderFrame* render_frame_; | |
52 | |
53 const GURL page_url_; | |
54 | |
55 bool render_frame_destroyed_; | |
56 | |
57 DISALLOW_COPY_AND_ASSIGN(ErrorCacheLoad); | |
58 }; | |
59 | |
60 #endif // CHROME_RENDERER_NET_ERROR_CACHE_LOAD_H_ | |
OLD | NEW |