| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
| 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
| 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
rights reserved. |
| 7 | 7 |
| 8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
| 9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
| 10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 return; | 219 return; |
| 220 | 220 |
| 221 if (m_cachedMetadata) { | 221 if (m_cachedMetadata) { |
| 222 const Vector<char>& serializedData = m_cachedMetadata->serialize(); | 222 const Vector<char>& serializedData = m_cachedMetadata->serialize(); |
| 223 Platform::current()->cacheMetadataInCacheStorage(response().url(), respo
nse().responseTime(), serializedData.data(), serializedData.size(), WebSecurityO
rigin(m_securityOrigin), response().cacheStorageCacheName()); | 223 Platform::current()->cacheMetadataInCacheStorage(response().url(), respo
nse().responseTime(), serializedData.data(), serializedData.size(), WebSecurityO
rigin(m_securityOrigin), response().cacheStorageCacheName()); |
| 224 } else { | 224 } else { |
| 225 Platform::current()->cacheMetadataInCacheStorage(response().url(), respo
nse().responseTime(), nullptr, 0, WebSecurityOrigin(m_securityOrigin), response(
).cacheStorageCacheName()); | 225 Platform::current()->cacheMetadataInCacheStorage(response().url(), respo
nse().responseTime(), nullptr, 0, WebSecurityOrigin(m_securityOrigin), response(
).cacheStorageCacheName()); |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 | 228 |
| 229 class Resource::ResourceCallback final : public GarbageCollectedFinalized<Resour
ceCallback> { | 229 // This class cannot be on-heap because the first callbackHandler() call |
| 230 // instantiates the singleton object while we can call it in the |
| 231 // pre-finalization step. |
| 232 class Resource::ResourceCallback final { |
| 230 public: | 233 public: |
| 231 static ResourceCallback& callbackHandler(); | 234 static ResourceCallback& callbackHandler(); |
| 232 DECLARE_TRACE(); | |
| 233 void schedule(Resource*); | 235 void schedule(Resource*); |
| 234 void cancel(Resource*); | 236 void cancel(Resource*); |
| 235 bool isScheduled(Resource*) const; | 237 bool isScheduled(Resource*) const; |
| 236 private: | 238 private: |
| 237 ResourceCallback(); | 239 ResourceCallback(); |
| 238 | 240 |
| 239 void runTask(); | 241 void runTask(); |
| 240 std::unique_ptr<CancellableTaskFactory> m_callbackTaskFactory; | 242 std::unique_ptr<CancellableTaskFactory> m_callbackTaskFactory; |
| 241 HeapHashSet<Member<Resource>> m_resourcesWithPendingClients; | 243 HashSet<Persistent<Resource>> m_resourcesWithPendingClients; |
| 242 }; | 244 }; |
| 243 | 245 |
| 244 Resource::ResourceCallback& Resource::ResourceCallback::callbackHandler() | 246 Resource::ResourceCallback& Resource::ResourceCallback::callbackHandler() |
| 245 { | 247 { |
| 246 // Oilpan + LSan: as the callbackHandler() singleton is used by Resource | 248 DEFINE_STATIC_LOCAL(ResourceCallback, callbackHandler, ()); |
| 247 // and ResourcePtr finalizers, it cannot be released upon shutdown in | |
| 248 // preparation for leak detection. | |
| 249 // | |
| 250 // Keep it out of LSan's reach instead. | |
| 251 LEAK_SANITIZER_DISABLED_SCOPE; | |
| 252 DEFINE_STATIC_LOCAL(ResourceCallback, callbackHandler, (new ResourceCallback
)); | |
| 253 return callbackHandler; | 249 return callbackHandler; |
| 254 } | 250 } |
| 255 | 251 |
| 256 DEFINE_TRACE(Resource::ResourceCallback) | |
| 257 { | |
| 258 visitor->trace(m_resourcesWithPendingClients); | |
| 259 } | |
| 260 | |
| 261 Resource::ResourceCallback::ResourceCallback() | 252 Resource::ResourceCallback::ResourceCallback() |
| 262 : m_callbackTaskFactory(CancellableTaskFactory::create(this, &ResourceCallba
ck::runTask)) | 253 : m_callbackTaskFactory(CancellableTaskFactory::create(this, &ResourceCallba
ck::runTask)) |
| 263 { | 254 { |
| 264 } | 255 } |
| 265 | 256 |
| 266 void Resource::ResourceCallback::schedule(Resource* resource) | 257 void Resource::ResourceCallback::schedule(Resource* resource) |
| 267 { | 258 { |
| 268 if (!m_callbackTaskFactory->isPending()) | 259 if (!m_callbackTaskFactory->isPending()) |
| 269 Platform::current()->currentThread()->scheduler()->loadingTaskRunner()->
postTask(BLINK_FROM_HERE, m_callbackTaskFactory->cancelAndCreate()); | 260 Platform::current()->currentThread()->scheduler()->loadingTaskRunner()->
postTask(BLINK_FROM_HERE, m_callbackTaskFactory->cancelAndCreate()); |
| 270 m_resourcesWithPendingClients.add(resource); | 261 m_resourcesWithPendingClients.add(resource); |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 case Resource::TextTrack: | 1056 case Resource::TextTrack: |
| 1066 case Resource::Media: | 1057 case Resource::Media: |
| 1067 case Resource::Manifest: | 1058 case Resource::Manifest: |
| 1068 return false; | 1059 return false; |
| 1069 } | 1060 } |
| 1070 ASSERT_NOT_REACHED(); | 1061 ASSERT_NOT_REACHED(); |
| 1071 return false; | 1062 return false; |
| 1072 } | 1063 } |
| 1073 | 1064 |
| 1074 } // namespace blink | 1065 } // namespace blink |
| OLD | NEW |