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

Side by Side Diff: Source/core/html/imports/HTMLImportsController.cpp

Issue 1032293002: Oilpan: dispose an HTMLImportsController on document detach/removal. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « Source/core/html/imports/HTMLImportsController.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 return name; 48 return name;
49 } 49 }
50 50
51 void HTMLImportsController::provideTo(Document& master) 51 void HTMLImportsController::provideTo(Document& master)
52 { 52 {
53 OwnPtrWillBeRawPtr<HTMLImportsController> controller = adoptPtrWillBeNoop(ne w HTMLImportsController(master)); 53 OwnPtrWillBeRawPtr<HTMLImportsController> controller = adoptPtrWillBeNoop(ne w HTMLImportsController(master));
54 master.setImportsController(controller.get()); 54 master.setImportsController(controller.get());
55 DocumentSupplement::provideTo(master, supplementName(), controller.release() ); 55 DocumentSupplement::provideTo(master, supplementName(), controller.release() );
56 } 56 }
57 57
58 void HTMLImportsController::removeFrom(Document& master) 58 void HTMLImportsController::removeFrom(Document& master)
haraken 2015/03/26 23:27:26 It seems that HTMLImportsController::removeFrom is
sof 2015/03/27 06:30:23 removeFrom() is called from Document upon detach;
59 { 59 {
60 HTMLImportsController* controller = master.importsController();
61 ASSERT(controller);
62 controller->dispose();
60 static_cast<DocumentSupplementable&>(master).removeSupplement(supplementName ()); 63 static_cast<DocumentSupplementable&>(master).removeSupplement(supplementName ());
61 master.setImportsController(nullptr); 64 master.setImportsController(nullptr);
62 } 65 }
63 66
64 HTMLImportsController::HTMLImportsController(Document& master) 67 HTMLImportsController::HTMLImportsController(Document& master)
65 : m_root(HTMLImportTreeRoot::create(&master)) 68 : m_root(HTMLImportTreeRoot::create(&master))
66 { 69 {
67 UseCounter::count(master, UseCounter::HTMLImports); 70 UseCounter::count(master, UseCounter::HTMLImports);
68 } 71 }
69 72
70 HTMLImportsController::~HTMLImportsController() 73 HTMLImportsController::~HTMLImportsController()
71 { 74 {
72 #if !ENABLE(OILPAN) 75 #if !ENABLE(OILPAN)
73 m_root.clear(); 76 dispose();
haraken 2015/03/26 23:27:26 As described above, I'm wondering why we need to c
sof 2015/03/27 08:44:31 You're right, it's not needed. Replaced with a non
74
75 for (size_t i = 0; i < m_loaders.size(); ++i)
76 m_loaders[i]->importDestroyed();
77 m_loaders.clear();
78 #endif 77 #endif
haraken 2015/03/26 23:27:26 In oilpan, we want to have an ASSERT to verify tha
79 } 78 }
80 79
80 void HTMLImportsController::dispose()
81 {
82 if (m_root) {
83 m_root->dispose();
84 m_root.clear();
85 }
86
87 for (size_t i = 0; i < m_loaders.size(); ++i)
88 m_loaders[i]->dispose();
89 m_loaders.clear();
90 }
91
81 static bool makesCycle(HTMLImport* parent, const KURL& url) 92 static bool makesCycle(HTMLImport* parent, const KURL& url)
82 { 93 {
83 for (HTMLImport* ancestor = parent; ancestor; ancestor = ancestor->parent()) { 94 for (HTMLImport* ancestor = parent; ancestor; ancestor = ancestor->parent()) {
84 if (!ancestor->isRoot() && equalIgnoringFragmentIdentifier(toHTMLImportC hild(parent)->url(), url)) 95 if (!ancestor->isRoot() && equalIgnoringFragmentIdentifier(toHTMLImportC hild(parent)->url(), url))
85 return true; 96 return true;
86 } 97 }
87 98
88 return false; 99 return false;
89 } 100 }
90 101
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 177 }
167 178
168 DEFINE_TRACE(HTMLImportsController) 179 DEFINE_TRACE(HTMLImportsController)
169 { 180 {
170 visitor->trace(m_root); 181 visitor->trace(m_root);
171 visitor->trace(m_loaders); 182 visitor->trace(m_loaders);
172 DocumentSupplement::trace(visitor); 183 DocumentSupplement::trace(visitor);
173 } 184 }
174 185
175 } // namespace blink 186 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/imports/HTMLImportsController.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698