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.
5 #ifndef CHROME_RENDERER_NET_ERROR_CACHE_LOAD_H_
6 #define CHROME_RENDERER_NET_ERROR_CACHE_LOAD_H_
8 #include "base/basictypes.h"
9 #include "content/public/renderer/render_frame_observer.h"
10 #include "gin/wrappable.h"
13 // ErrorCacheLoad class:
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.
25 class ErrorCacheLoad
: public gin::Wrappable
<ErrorCacheLoad
>,
26 public content::RenderFrameObserver
{
28 static gin::WrapperInfo kWrapperInfo
;
30 static void Install(content::RenderFrame
* render_frame
, const GURL
& page_url
);
33 ErrorCacheLoad(content::RenderFrame
* render_frame
, const GURL
& page_url
);
34 virtual ~ErrorCacheLoad();
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();
42 virtual gin::ObjectTemplateBuilder
GetObjectTemplateBuilder(
43 v8::Isolate
* isolate
) OVERRIDE
;
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
;
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_
;
55 bool render_frame_destroyed_
;
57 DISALLOW_COPY_AND_ASSIGN(ErrorCacheLoad
);
60 #endif // CHROME_RENDERER_NET_ERROR_CACHE_LOAD_H_