OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2012 Motorola Mobility Inc. | 2 * Copyright (C) 2012 Motorola Mobility Inc. |
3 * Copyright (C) 2013 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2013 Google Inc. All Rights Reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 18 matching lines...) Expand all Loading... | |
29 #include "core/fetch/MemoryCache.h" | 29 #include "core/fetch/MemoryCache.h" |
30 #include "core/html/URLRegistry.h" | 30 #include "core/html/URLRegistry.h" |
31 #include "platform/weborigin/KURL.h" | 31 #include "platform/weborigin/KURL.h" |
32 #include "wtf/Vector.h" | 32 #include "wtf/Vector.h" |
33 #include "wtf/text/StringHash.h" | 33 #include "wtf/text/StringHash.h" |
34 | 34 |
35 namespace blink { | 35 namespace blink { |
36 | 36 |
37 PassOwnPtrWillBeRawPtr<PublicURLManager> PublicURLManager::create(ExecutionConte xt* context) | 37 PassOwnPtrWillBeRawPtr<PublicURLManager> PublicURLManager::create(ExecutionConte xt* context) |
38 { | 38 { |
39 OwnPtrWillBeRawPtr<PublicURLManager> publicURLManager = adoptPtrWillBeNoop(n ew PublicURLManager(context)); | 39 return adoptPtrWillBeNoop(new PublicURLManager(context)); |
40 publicURLManager->suspendIfNeeded(); | |
41 return publicURLManager.release(); | |
42 } | 40 } |
43 | 41 |
44 PublicURLManager::PublicURLManager(ExecutionContext* context) | 42 PublicURLManager::PublicURLManager(ExecutionContext* context) |
45 : ActiveDOMObject(context) | 43 : ContextLifecycleObserver(context) |
46 , m_isStopped(false) | |
47 { | 44 { |
48 } | 45 } |
49 | 46 |
50 void PublicURLManager::registerURL(SecurityOrigin* origin, const KURL& url, URLR egistrable* registrable, const String& uuid) | 47 void PublicURLManager::registerURL(SecurityOrigin* origin, const KURL& url, URLR egistrable* registrable, const String& uuid) |
51 { | 48 { |
52 if (m_isStopped) | 49 if (!executionContext()) |
haraken
2016/03/03 15:31:35
Sigbjorn: Should we revert this CL for the same re
sof
2016/03/03 15:43:53
Reinstating m_isStopped for PublicURLManager as a
| |
53 return; | 50 return; |
54 | 51 |
55 RegistryURLMap::ValueType* found = m_registryToURL.add(®istrable->registr y(), URLMap()).storedValue; | 52 RegistryURLMap::ValueType* found = m_registryToURL.add(®istrable->registr y(), URLMap()).storedValue; |
56 found->key->registerURL(origin, url, registrable); | 53 found->key->registerURL(origin, url, registrable); |
57 found->value.add(url.string(), uuid); | 54 found->value.add(url.string(), uuid); |
58 } | 55 } |
59 | 56 |
60 void PublicURLManager::revoke(const KURL& url) | 57 void PublicURLManager::revoke(const KURL& url) |
61 { | 58 { |
62 for (auto& registryUrl : m_registryToURL) { | 59 for (auto& registryUrl : m_registryToURL) { |
(...skipping 19 matching lines...) Expand all Loading... | |
82 registry->unregisterURL(url); | 79 registry->unregisterURL(url); |
83 urlsToRemove.append(registeredUrl.key); | 80 urlsToRemove.append(registeredUrl.key); |
84 } | 81 } |
85 } | 82 } |
86 for (unsigned j = 0; j < urlsToRemove.size(); j++) | 83 for (unsigned j = 0; j < urlsToRemove.size(); j++) |
87 registeredURLs.remove(urlsToRemove[j]); | 84 registeredURLs.remove(urlsToRemove[j]); |
88 urlsToRemove.clear(); | 85 urlsToRemove.clear(); |
89 } | 86 } |
90 } | 87 } |
91 | 88 |
92 void PublicURLManager::stop() | 89 void PublicURLManager::contextDestroyed() |
93 { | 90 { |
94 if (m_isStopped) | 91 if (!executionContext()) |
95 return; | 92 return; |
96 | 93 |
97 m_isStopped = true; | |
98 for (auto& registryUrl : m_registryToURL) { | 94 for (auto& registryUrl : m_registryToURL) { |
99 for (auto& url : registryUrl.value) | 95 for (auto& url : registryUrl.value) |
100 registryUrl.key->unregisterURL(KURL(ParsedURLString, url.key)); | 96 registryUrl.key->unregisterURL(KURL(ParsedURLString, url.key)); |
101 } | 97 } |
102 | 98 |
103 m_registryToURL.clear(); | 99 m_registryToURL.clear(); |
104 } | 100 } |
105 | 101 |
106 DEFINE_TRACE(PublicURLManager) | 102 DEFINE_TRACE(PublicURLManager) |
107 { | 103 { |
108 ActiveDOMObject::trace(visitor); | 104 ContextLifecycleObserver::trace(visitor); |
109 } | 105 } |
110 | 106 |
111 } // namespace blink | 107 } // namespace blink |
OLD | NEW |