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

Side by Side Diff: Source/core/html/PublicURLManager.cpp

Issue 157363003: Implement Blob.close(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Avoid warning from PHP's fread() on empty reads Created 6 years, 10 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) 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 11 matching lines...) Expand all
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/html/PublicURLManager.h" 28 #include "core/html/PublicURLManager.h"
29 29
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/text/StringHash.h" 33 #include "wtf/text/StringHash.h"
33 34
34 namespace WebCore { 35 namespace WebCore {
35 36
36 PassOwnPtr<PublicURLManager> PublicURLManager::create(ExecutionContext* context) 37 PassOwnPtr<PublicURLManager> PublicURLManager::create(ExecutionContext* context)
37 { 38 {
38 OwnPtr<PublicURLManager> publicURLManager(adoptPtr(new PublicURLManager(cont ext))); 39 OwnPtr<PublicURLManager> publicURLManager(adoptPtr(new PublicURLManager(cont ext)));
39 publicURLManager->suspendIfNeeded(); 40 publicURLManager->suspendIfNeeded();
40 return publicURLManager.release(); 41 return publicURLManager.release();
41 } 42 }
42 43
43 PublicURLManager::PublicURLManager(ExecutionContext* context) 44 PublicURLManager::PublicURLManager(ExecutionContext* context)
44 : ActiveDOMObject(context) 45 : ActiveDOMObject(context)
45 , m_isStopped(false) 46 , m_isStopped(false)
46 { 47 {
47 } 48 }
48 49
49 void PublicURLManager::registerURL(SecurityOrigin* origin, const KURL& url, URLR egistrable* registrable) 50 void PublicURLManager::registerURL(SecurityOrigin* origin, const KURL& url, URLR egistrable* registrable, const String& uuid)
50 { 51 {
51 if (m_isStopped) 52 if (m_isStopped)
52 return; 53 return;
53 54
54 RegistryURLMap::iterator found = m_registryToURL.add(&registrable->registry( ), URLSet()).iterator; 55 RegistryURLMap::iterator found = m_registryToURL.add(&registrable->registry( ), URLMap()).iterator;
55 found->key->registerURL(origin, url, registrable); 56 found->key->registerURL(origin, url, registrable);
56 found->value.add(url.string()); 57 found->value.add(url.string(), uuid);
57 } 58 }
58 59
59 void PublicURLManager::revoke(const KURL& url) 60 void PublicURLManager::revoke(const KURL& url)
60 { 61 {
61 for (RegistryURLMap::iterator i = m_registryToURL.begin(); i != m_registryTo URL.end(); ++i) { 62 for (RegistryURLMap::iterator i = m_registryToURL.begin(); i != m_registryTo URL.end(); ++i) {
62 if (i->value.contains(url.string())) { 63 if (i->value.contains(url.string())) {
63 i->key->unregisterURL(url); 64 i->key->unregisterURL(url);
64 i->value.remove(url.string()); 65 i->value.remove(url.string());
65 break; 66 break;
66 } 67 }
67 } 68 }
68 } 69 }
69 70
71 void PublicURLManager::revoke(const String& uuid)
72 {
73 // A linear scan; revoking by UUID is assumed rare.
74 Vector<String> removableKeys;
75 for (RegistryURLMap::iterator i = m_registryToURL.begin(); i != m_registryTo URL.end(); ++i) {
76 for (URLMap::iterator j = i->value.begin(); j != i->value.end(); ++j) {
77 if (uuid == j->value) {
78 i->key->unregisterURL(KURL(ParsedURLString, j->key));
79 removableKeys.append(j->key);
80 }
81 }
82 if (removableKeys.size()) {
83 for (unsigned j = 0; j < removableKeys.size(); j++)
84 i->value.remove(removableKeys[j]);
85 removableKeys.clear();
86 }
kinuko 2014/02/12 06:11:20 It might be slightly more readable if we just main
sof 2014/02/12 06:56:47 It would have to be UUID to a set of URLs; would t
kinuko 2014/02/12 12:52:00 I guessed in general this map'd be relatively smal
sof 2014/02/13 09:59:57 Thanks, I've tried to improve readability - please
87 }
88 }
89
70 void PublicURLManager::stop() 90 void PublicURLManager::stop()
71 { 91 {
72 if (m_isStopped) 92 if (m_isStopped)
73 return; 93 return;
74 94
75 m_isStopped = true; 95 m_isStopped = true;
76 for (RegistryURLMap::iterator i = m_registryToURL.begin(); i != m_registryTo URL.end(); ++i) { 96 for (RegistryURLMap::iterator i = m_registryToURL.begin(); i != m_registryTo URL.end(); ++i) {
77 for (URLSet::iterator j = i->value.begin(); j != i->value.end(); ++j) 97 for (URLMap::iterator j = i->value.begin(); j != i->value.end(); ++j)
78 i->key->unregisterURL(KURL(ParsedURLString, *j)); 98 i->key->unregisterURL(KURL(ParsedURLString, j->key));
79 } 99 }
80 100
81 m_registryToURL.clear(); 101 m_registryToURL.clear();
82 } 102 }
83 103
84 } 104 }
OLDNEW
« Source/core/fileapi/FileReader.cpp ('K') | « Source/core/html/PublicURLManager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698