summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_system_quota_manager.h
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-09 06:59:16 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-09 06:59:16 +0000
commit6c20697e6da610f40947526bbd65dbda0579445c (patch)
tree97989a6b4e28a59038e7656c79d0502ba14b8bdd /webkit/fileapi/file_system_quota_manager.h
parentcc9c9d751953abd0230d7ae22ac2be27b2d9b632 (diff)
downloadchromium_src-6c20697e6da610f40947526bbd65dbda0579445c.zip
chromium_src-6c20697e6da610f40947526bbd65dbda0579445c.tar.gz
chromium_src-6c20697e6da610f40947526bbd65dbda0579445c.tar.bz2
FileSystem code cleanup 1st cut - does some class renaming.
Renamed FileSystemQuota to FileSystemQuotaManager. Removed PlatFormErrorToFileError in simple_file_system.cc (in favor of webkit_flue::PlatformErrorToFileError) BUG=60243 TEST=none Review URL: http://codereview.chromium.org/4017007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65506 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_system_quota_manager.h')
-rw-r--r--webkit/fileapi/file_system_quota_manager.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/webkit/fileapi/file_system_quota_manager.h b/webkit/fileapi/file_system_quota_manager.h
new file mode 100644
index 0000000..f1c94e1
--- /dev/null
+++ b/webkit/fileapi/file_system_quota_manager.h
@@ -0,0 +1,52 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_MANAGER_H_
+#define WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_MANAGER_H_
+
+#include <set>
+
+#include "base/basictypes.h"
+#include "googleurl/src/gurl.h"
+
+namespace fileapi {
+
+// A quota manager for FileSystem. For now it has little implementation
+// and just allows unlimited quota for apps.
+class FileSystemQuotaManager {
+ public:
+ static const int64 kUnknownSize;
+
+ // If |allow_file_access_from_files| is true, unlimited access is granted
+ // for file:/// URLs.
+ // If |unlimited_quota| is true, unlimited access is granted for every
+ // origin. This flag must be used only for testing.
+ FileSystemQuotaManager(bool allow_file_access_from_files,
+ bool unlimited_quota);
+ ~FileSystemQuotaManager();
+
+ // Checks if the origin can grow its usage by |growth| bytes.
+ // This only performs in-memory check and returns immediately.
+ // For now it just returns false for any origins (regardless of the size)
+ // that are not in the in-memory unlimited_quota_origins map.
+ bool CheckOriginQuota(const GURL& origin, int64 growth);
+
+ // Maintains origins in memory that are allowed to have unlimited quota.
+ void SetOriginQuotaUnlimited(const GURL& origin);
+ void ResetOriginQuotaUnlimited(const GURL& origin);
+ bool CheckIfOriginGrantedUnlimitedQuota(const GURL& origin);
+
+ private:
+ // For some extensions/apps we allow unlimited quota.
+ std::set<GURL> unlimited_quota_origins_;
+
+ const bool allow_file_access_from_files_;
+ const bool unlimited_quota_;
+
+ DISALLOW_COPY_AND_ASSIGN(FileSystemQuotaManager);
+};
+
+} // namespace fileapi
+
+#endif // WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_MANAGER_H_