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

Side by Side Diff: third_party/WebKit/Source/modules/webdatabase/QuotaTracker.cpp

Issue 1914763002: QuotaTracker: Use 'raw' string as key for origin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unit tests Created 4 years, 8 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 return tracker; 44 return tracker;
45 } 45 }
46 46
47 void QuotaTracker::getDatabaseSizeAndSpaceAvailableToOrigin( 47 void QuotaTracker::getDatabaseSizeAndSpaceAvailableToOrigin(
48 SecurityOrigin* origin, const String& databaseName, 48 SecurityOrigin* origin, const String& databaseName,
49 unsigned long long* databaseSize, unsigned long long* spaceAvailable) 49 unsigned long long* databaseSize, unsigned long long* spaceAvailable)
50 { 50 {
51 // Extra scope to unlock prior to potentially calling Platform. 51 // Extra scope to unlock prior to potentially calling Platform.
52 { 52 {
53 MutexLocker lockData(m_dataGuard); 53 MutexLocker lockData(m_dataGuard);
54 ASSERT(m_databaseSizes.contains(origin->toString())); 54 ASSERT(m_databaseSizes.contains(origin->toRawString()));
55 HashMap<String, SizeMap>::const_iterator it = m_databaseSizes.find(origi n->toString()); 55 HashMap<String, SizeMap>::const_iterator it = m_databaseSizes.find(origi n->toRawString());
56 ASSERT(it->value.contains(databaseName)); 56 ASSERT(it->value.contains(databaseName));
57 *databaseSize = it->value.get(databaseName); 57 *databaseSize = it->value.get(databaseName);
58 58
59 if (m_spaceAvailableToOrigins.contains(origin->toString())) { 59 if (m_spaceAvailableToOrigins.contains(origin->toRawString())) {
60 *spaceAvailable = m_spaceAvailableToOrigins.get(origin->toString()); 60 *spaceAvailable = m_spaceAvailableToOrigins.get(origin->toRawString( ));
61 return; 61 return;
62 } 62 }
63 } 63 }
64 64
65 // The embedder hasn't pushed this value to us, so we pull it as needed. 65 // The embedder hasn't pushed this value to us, so we pull it as needed.
66 *spaceAvailable = Platform::current()->databaseGetSpaceAvailableForOrigin(We bSecurityOrigin(origin)); 66 *spaceAvailable = Platform::current()->databaseGetSpaceAvailableForOrigin(We bSecurityOrigin(origin));
67 } 67 }
68 68
69 void QuotaTracker::updateDatabaseSize( 69 void QuotaTracker::updateDatabaseSize(
70 SecurityOrigin* origin, const String& databaseName, 70 SecurityOrigin* origin, const String& databaseName,
71 unsigned long long databaseSize) 71 unsigned long long databaseSize)
72 { 72 {
73 MutexLocker lockData(m_dataGuard); 73 MutexLocker lockData(m_dataGuard);
74 HashMap<String, SizeMap>::ValueType* it = m_databaseSizes.add(origin->toStri ng(), SizeMap()).storedValue; 74 HashMap<String, SizeMap>::ValueType* it = m_databaseSizes.add(origin->toRawS tring(), SizeMap()).storedValue;
75 it->value.set(databaseName, databaseSize); 75 it->value.set(databaseName, databaseSize);
76 } 76 }
77 77
78 void QuotaTracker::updateSpaceAvailableToOrigin(SecurityOrigin* origin, unsigned long long spaceAvailable) 78 void QuotaTracker::updateSpaceAvailableToOrigin(SecurityOrigin* origin, unsigned long long spaceAvailable)
79 { 79 {
80 MutexLocker lockData(m_dataGuard); 80 MutexLocker lockData(m_dataGuard);
81 m_spaceAvailableToOrigins.set(origin->toString(), spaceAvailable); 81 m_spaceAvailableToOrigins.set(origin->toRawString(), spaceAvailable);
82 } 82 }
83 83
84 void QuotaTracker::resetSpaceAvailableToOrigin(SecurityOrigin* origin) 84 void QuotaTracker::resetSpaceAvailableToOrigin(SecurityOrigin* origin)
85 { 85 {
86 MutexLocker lockData(m_dataGuard); 86 MutexLocker lockData(m_dataGuard);
87 m_spaceAvailableToOrigins.remove(origin->toString()); 87 m_spaceAvailableToOrigins.remove(origin->toRawString());
88 } 88 }
89 89
90 } // namespace blink 90 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/modules.gypi ('k') | third_party/WebKit/Source/modules/webdatabase/QuotaTrackerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698