Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / webkit / browser / quota / quota_manager.cc
index 244c6b4..a7e466e 100644 (file)
@@ -55,6 +55,12 @@ const int64 QuotaManager::kNoLimit = kint64max;
 
 const int QuotaManager::kPerHostTemporaryPortion = 5;  // 20%
 
+// Cap size for per-host persistent quota determined by the histogram.
+// This is a bit lax value because the histogram says nothing about per-host
+// persistent storage usage and we determined by global persistent storage
+// usage that is less than 10GB for almost all users.
+const int64 QuotaManager::kPerHostPersistentQuotaLimit = 10 * 1024 * kMBytes;
+
 const char QuotaManager::kDatabaseName[] = "QuotaManager";
 
 // Preserve kMinimumPreserveForSystem disk space for system book-keeping
@@ -987,7 +993,7 @@ void QuotaManager::SetTemporaryGlobalOverrideQuota(
   }
 
   if (db_disabled_) {
-    if (callback.is_null())
+    if (!callback.is_null())
       callback.Run(kQuotaErrorInvalidAccess, -1);
     return;
   }
@@ -1038,11 +1044,17 @@ void QuotaManager::SetPersistentHostQuota(const std::string& host,
     callback.Run(kQuotaErrorNotSupported, 0);
     return;
   }
+
   if (new_quota < 0) {
     callback.Run(kQuotaErrorInvalidModification, -1);
     return;
   }
 
+  if (kPerHostPersistentQuotaLimit < new_quota) {
+    // Cap the requested size at the per-host quota limit.
+    new_quota = kPerHostPersistentQuotaLimit;
+  }
+
   if (db_disabled_) {
     callback.Run(kQuotaErrorInvalidAccess, -1);
     return;