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

Side by Side Diff: third_party/WebKit/Source/core/inspector/InspectorResourceContentLoader.cpp

Issue 1436723005: Oilpan: tidy up InspectorResourceContentLoader's ResourceClient handling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/inspector/InspectorResourceContentLoader.h" 6 #include "core/inspector/InspectorResourceContentLoader.h"
7 7
8 #include "core/css/CSSStyleSheet.h" 8 #include "core/css/CSSStyleSheet.h"
9 #include "core/css/StyleSheetContents.h" 9 #include "core/css/StyleSheetContents.h"
10 #include "core/dom/Document.h" 10 #include "core/dom/Document.h"
11 #include "core/fetch/CSSStyleSheetResource.h" 11 #include "core/fetch/CSSStyleSheetResource.h"
12 #include "core/fetch/FetchInitiatorTypeNames.h" 12 #include "core/fetch/FetchInitiatorTypeNames.h"
13 #include "core/fetch/RawResource.h" 13 #include "core/fetch/RawResource.h"
14 #include "core/fetch/Resource.h" 14 #include "core/fetch/Resource.h"
15 #include "core/fetch/ResourceFetcher.h" 15 #include "core/fetch/ResourceFetcher.h"
16 #include "core/fetch/ResourcePtr.h" 16 #include "core/fetch/ResourcePtr.h"
17 #include "core/fetch/StyleSheetResourceClient.h" 17 #include "core/fetch/StyleSheetResourceClient.h"
18 #include "core/frame/LocalFrame.h" 18 #include "core/frame/LocalFrame.h"
19 #include "core/inspector/InspectedFrames.h" 19 #include "core/inspector/InspectedFrames.h"
20 #include "core/inspector/InspectorCSSAgent.h" 20 #include "core/inspector/InspectorCSSAgent.h"
21 #include "core/inspector/InspectorPageAgent.h" 21 #include "core/inspector/InspectorPageAgent.h"
22 #include "core/page/Page.h" 22 #include "core/page/Page.h"
23 #include "public/platform/WebURLRequest.h" 23 #include "public/platform/WebURLRequest.h"
24 24
25 namespace blink { 25 namespace blink {
26 26
27 class InspectorResourceContentLoader::ResourceClient final : private RawResource Client, private StyleSheetResourceClient { 27 class InspectorResourceContentLoader::ResourceClient final : public NoBaseWillBe GarbageCollectedFinalized<InspectorResourceContentLoader::ResourceClient>, priva te RawResourceClient, private StyleSheetResourceClient {
28 public: 28 public:
29 ResourceClient(InspectorResourceContentLoader* loader) 29 explicit ResourceClient(InspectorResourceContentLoader* loader)
30 : m_loader(loader) 30 : m_loader(loader)
31 { 31 {
32 } 32 }
33 33
34 void waitForResource(Resource* resource) 34 void waitForResource(Resource* resource)
35 { 35 {
36 if (resource->type() == Resource::Raw) 36 if (resource->type() == Resource::Raw)
37 resource->addClient(static_cast<RawResourceClient*>(this)); 37 resource->addClient(static_cast<RawResourceClient*>(this));
38 else 38 else
39 resource->addClient(static_cast<StyleSheetResourceClient*>(this)); 39 resource->addClient(static_cast<StyleSheetResourceClient*>(this));
40 } 40 }
41 41
42 DEFINE_INLINE_TRACE()
43 {
44 visitor->trace(m_loader);
45 }
46
42 private: 47 private:
43 InspectorResourceContentLoader* m_loader; 48 RawPtrWillBeMember<InspectorResourceContentLoader> m_loader;
44 49
45 void setCSSStyleSheet(const String&, const KURL&, const String&, const CSSSt yleSheetResource*) override; 50 void setCSSStyleSheet(const String&, const KURL&, const String&, const CSSSt yleSheetResource*) override;
46 void notifyFinished(Resource*) override; 51 void notifyFinished(Resource*) override;
47 String debugName() const override { return "InspectorResourceContentLoader:: ResourceClient"; } 52 String debugName() const override { return "InspectorResourceContentLoader:: ResourceClient"; }
48 void resourceFinished(Resource*); 53 void resourceFinished(Resource*);
49 54
50 friend class InspectorResourceContentLoader; 55 friend class InspectorResourceContentLoader;
51 }; 56 };
52 57
53 void InspectorResourceContentLoader::ResourceClient::resourceFinished(Resource* resource) 58 void InspectorResourceContentLoader::ResourceClient::resourceFinished(Resource* resource)
54 { 59 {
55 if (m_loader) 60 if (m_loader)
56 m_loader->resourceFinished(this); 61 m_loader->resourceFinished(this);
57 62
58 if (resource->type() == Resource::Raw) 63 if (resource->type() == Resource::Raw)
59 resource->removeClient(static_cast<RawResourceClient*>(this)); 64 resource->removeClient(static_cast<RawResourceClient*>(this));
60 else 65 else
61 resource->removeClient(static_cast<StyleSheetResourceClient*>(this)); 66 resource->removeClient(static_cast<StyleSheetResourceClient*>(this));
62 67
68 #if !ENABLE(OILPAN)
63 delete this; 69 delete this;
70 #endif
64 } 71 }
65 72
66 void InspectorResourceContentLoader::ResourceClient::setCSSStyleSheet(const Stri ng&, const KURL& url, const String&, const CSSStyleSheetResource* resource) 73 void InspectorResourceContentLoader::ResourceClient::setCSSStyleSheet(const Stri ng&, const KURL& url, const String&, const CSSStyleSheetResource* resource)
67 { 74 {
68 resourceFinished(const_cast<CSSStyleSheetResource*>(resource)); 75 resourceFinished(const_cast<CSSStyleSheetResource*>(resource));
69 } 76 }
70 77
71 void InspectorResourceContentLoader::ResourceClient::notifyFinished(Resource* re source) 78 void InspectorResourceContentLoader::ResourceClient::notifyFinished(Resource* re source)
72 { 79 {
73 if (resource->type() == Resource::CSSStyleSheet) 80 if (resource->type() == Resource::CSSStyleSheet)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 checkDone(); 158 checkDone();
152 } 159 }
153 160
154 InspectorResourceContentLoader::~InspectorResourceContentLoader() 161 InspectorResourceContentLoader::~InspectorResourceContentLoader()
155 { 162 {
156 ASSERT(m_resources.isEmpty()); 163 ASSERT(m_resources.isEmpty());
157 } 164 }
158 165
159 DEFINE_TRACE(InspectorResourceContentLoader) 166 DEFINE_TRACE(InspectorResourceContentLoader)
160 { 167 {
168 #if ENABLE(OILPAN)
161 visitor->trace(m_inspectedFrame); 169 visitor->trace(m_inspectedFrame);
170 visitor->trace(m_pendingResourceClients);
171 #endif
162 } 172 }
163 173
164 void InspectorResourceContentLoader::didCommitLoadForLocalFrame(LocalFrame* fram e) 174 void InspectorResourceContentLoader::didCommitLoadForLocalFrame(LocalFrame* fram e)
165 { 175 {
166 if (frame == m_inspectedFrame) 176 if (frame == m_inspectedFrame)
167 stop(); 177 stop();
168 } 178 }
169 179
170 void InspectorResourceContentLoader::dispose() 180 void InspectorResourceContentLoader::dispose()
171 { 181 {
172 stop(); 182 stop();
173 } 183 }
174 184
175 void InspectorResourceContentLoader::stop() 185 void InspectorResourceContentLoader::stop()
176 { 186 {
177 HashSet<ResourceClient*> pendingResourceClients; 187 WillBeHeapHashSet<RawPtrWillBeMember<ResourceClient>> pendingResourceClients ;
178 m_pendingResourceClients.swap(pendingResourceClients); 188 m_pendingResourceClients.swap(pendingResourceClients);
179 for (const auto& client : pendingResourceClients) 189 for (const auto& client : pendingResourceClients)
180 client->m_loader = nullptr; 190 client->m_loader = nullptr;
181 m_resources.clear(); 191 m_resources.clear();
182 // Make sure all callbacks are called to prevent infinite waiting time. 192 // Make sure all callbacks are called to prevent infinite waiting time.
183 checkDone(); 193 checkDone();
184 m_allRequestsStarted = false; 194 m_allRequestsStarted = false;
185 m_started = false; 195 m_started = false;
186 } 196 }
187 197
(...skipping 12 matching lines...) Expand all
200 (*callback)(); 210 (*callback)();
201 } 211 }
202 212
203 void InspectorResourceContentLoader::resourceFinished(ResourceClient* client) 213 void InspectorResourceContentLoader::resourceFinished(ResourceClient* client)
204 { 214 {
205 m_pendingResourceClients.remove(client); 215 m_pendingResourceClients.remove(client);
206 checkDone(); 216 checkDone();
207 } 217 }
208 218
209 } // namespace blink 219 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698