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

Side by Side Diff: third_party/WebKit/Source/core/loader/PrerenderHandle.cpp

Issue 1862593005: Prerender need to be on the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 30 matching lines...) Expand all
41 namespace blink { 41 namespace blink {
42 42
43 // static 43 // static
44 PrerenderHandle* PrerenderHandle::create(Document& document, PrerenderClient* cl ient, const KURL& url, const unsigned prerenderRelTypes) 44 PrerenderHandle* PrerenderHandle::create(Document& document, PrerenderClient* cl ient, const KURL& url, const unsigned prerenderRelTypes)
45 { 45 {
46 // Prerenders are unlike requests in most ways (for instance, they pass down fragments, and they don't return data), 46 // Prerenders are unlike requests in most ways (for instance, they pass down fragments, and they don't return data),
47 // but they do have referrers. 47 // but they do have referrers.
48 if (!document.frame()) 48 if (!document.frame())
49 return nullptr; 49 return nullptr;
50 50
51 RefPtr<Prerender> prerender = Prerender::create(client, url, prerenderRelTyp es, SecurityPolicy::generateReferrer(document.getReferrerPolicy(), url, document .outgoingReferrer())); 51 Prerender* prerender = Prerender::create(client, url, prerenderRelTypes, Sec urityPolicy::generateReferrer(document.getReferrerPolicy(), url, document.outgoi ngReferrer()));
52 52
53 PrerendererClient* prerendererClient = PrerendererClient::from(document.page ()); 53 PrerendererClient* prerendererClient = PrerendererClient::from(document.page ());
54 if (prerendererClient) 54 if (prerendererClient)
55 prerendererClient->willAddPrerender(prerender.get()); 55 prerendererClient->willAddPrerender(prerender);
56 prerender->add(); 56 prerender->add();
57 57
58 return new PrerenderHandle(document, prerender.release()); 58 return new PrerenderHandle(document, prerender);
59 } 59 }
60 60
61 PrerenderHandle::PrerenderHandle(Document& document, PassRefPtr<Prerender> prere nder) 61 PrerenderHandle::PrerenderHandle(Document& document, Prerender* prerender)
62 : DocumentLifecycleObserver(&document) 62 : DocumentLifecycleObserver(&document)
63 , m_prerender(prerender) 63 , m_prerender(prerender)
64 { 64 {
65 } 65 }
66 66
67 PrerenderHandle::~PrerenderHandle() 67 PrerenderHandle::~PrerenderHandle()
68 { 68 {
69 if (m_prerender) 69 if (m_prerender)
70 detach(); 70 detach();
haraken 2016/04/07 00:08:12 Now you cannot touch m_prerender in the destructor
sof 2016/04/07 05:12:13 Like for other eagerly finalized objects, you can
71 } 71 }
72 72
73 void PrerenderHandle::cancel() 73 void PrerenderHandle::cancel()
74 { 74 {
75 // Avoid both abandoning and canceling the same prerender. In the abandon ca se, the LinkLoader cancels the 75 // Avoid both abandoning and canceling the same prerender. In the abandon ca se, the LinkLoader cancels the
76 // PrerenderHandle as the Document is destroyed, even through the DocumentLi fecycleObserver has already abandoned 76 // PrerenderHandle as the Document is destroyed, even through the DocumentLi fecycleObserver has already abandoned
77 // it. 77 // it.
78 if (!m_prerender) 78 if (!m_prerender)
79 return; 79 return;
80 m_prerender->cancel(); 80 m_prerender->cancel();
(...skipping 13 matching lines...) Expand all
94 // that is already canceled (and thus detached). In that case, 94 // that is already canceled (and thus detached). In that case,
95 // we should not detach the PrerenderHandle again, so we need this check. 95 // we should not detach the PrerenderHandle again, so we need this check.
96 if (!m_prerender) 96 if (!m_prerender)
97 return; 97 return;
98 m_prerender->abandon(); 98 m_prerender->abandon();
99 detach(); 99 detach();
100 } 100 }
101 101
102 void PrerenderHandle::detach() 102 void PrerenderHandle::detach()
103 { 103 {
104 m_prerender->removeClient(); 104 m_prerender->dispose();
105 m_prerender.clear(); 105 m_prerender.clear();
106 } 106 }
107 107
108 DEFINE_TRACE(PrerenderHandle) 108 DEFINE_TRACE(PrerenderHandle)
109 { 109 {
110 visitor->trace(m_prerender);
110 DocumentLifecycleObserver::trace(visitor); 111 DocumentLifecycleObserver::trace(visitor);
111 } 112 }
112 113
113 } // namespace blink 114 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/PrerenderHandle.h ('k') | third_party/WebKit/Source/platform/Prerender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698