| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_H_ |
| 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
| 12 | 12 |
| 13 namespace fileapi { | 13 namespace fileapi { |
| 14 | 14 |
| 15 // A quota manager for FileSystem. For now it has little implementation | 15 // A quota manager for FileSystem. For now it has little implementation |
| 16 // and just allows unlimited quota for apps. | 16 // and just allows unlimited quota for apps. |
| 17 class FileSystemQuota { | 17 class FileSystemQuota { |
| 18 public: | 18 public: |
| 19 FileSystemQuota() { } | |
| 20 static const int64 kUnknownSize; | 19 static const int64 kUnknownSize; |
| 21 | 20 |
| 21 FileSystemQuota(); |
| 22 ~FileSystemQuota(); |
| 23 |
| 22 // Checks if the origin can grow its usage by |growth| bytes. | 24 // Checks if the origin can grow its usage by |growth| bytes. |
| 23 // This only performs in-memory check and returns immediately. | 25 // This only performs in-memory check and returns immediately. |
| 24 // For now it just returns false for any origins (regardless of the size) | 26 // For now it just returns false for any origins (regardless of the size) |
| 25 // that are not in the in-memory unlimited_quota_origins map. | 27 // that are not in the in-memory unlimited_quota_origins map. |
| 26 bool CheckOriginQuota(const GURL& origin, int64 growth); | 28 bool CheckOriginQuota(const GURL& origin, int64 growth); |
| 27 | 29 |
| 28 // Maintains origins in memory that are allowed to have unlimited quota. | 30 // Maintains origins in memory that are allowed to have unlimited quota. |
| 29 void SetOriginQuotaUnlimited(const GURL& origin); | 31 void SetOriginQuotaUnlimited(const GURL& origin); |
| 30 void ResetOriginQuotaUnlimited(const GURL& origin); | 32 void ResetOriginQuotaUnlimited(const GURL& origin); |
| 31 bool CheckIfOriginGrantedUnlimitedQuota(const GURL& origin); | 33 bool CheckIfOriginGrantedUnlimitedQuota(const GURL& origin); |
| 32 | 34 |
| 33 private: | 35 private: |
| 34 // For some extensions/apps we allow unlimited quota. | 36 // For some extensions/apps we allow unlimited quota. |
| 35 std::set<GURL> unlimited_quota_origins_; | 37 std::set<GURL> unlimited_quota_origins_; |
| 36 | 38 |
| 37 DISALLOW_COPY_AND_ASSIGN(FileSystemQuota); | 39 DISALLOW_COPY_AND_ASSIGN(FileSystemQuota); |
| 38 }; | 40 }; |
| 39 | 41 |
| 40 } // namespace fileapi | 42 } // namespace fileapi |
| 41 | 43 |
| 42 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_H_ | 44 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_H_ |
| OLD | NEW |