OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_BROWSER_FILEAPI_QUOTA_OPEN_FILE_HANDLE_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_QUOTA_OPEN_FILE_HANDLE_H_ |
6 #define WEBKIT_BROWSER_FILEAPI_QUOTA_OPEN_FILE_HANDLE_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_QUOTA_OPEN_FILE_HANDLE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "webkit/browser/webkit_storage_browser_export.h" | 11 #include "webkit/browser/webkit_storage_browser_export.h" |
12 | 12 |
13 namespace fileapi { | 13 namespace fileapi { |
14 | 14 |
15 class QuotaReservation; | 15 class QuotaReservation; |
16 class OpenFileHandleContext; | 16 class OpenFileHandleContext; |
17 class QuotaReservationBuffer; | 17 class QuotaReservationBuffer; |
18 | 18 |
19 // Represents an open file like a file descriptor. | 19 // Represents an open file like a file descriptor. |
20 // This should be alive while a consumer keeps a file opened and should be | 20 // This should be alive while a consumer keeps a file opened and should be |
21 // deleted when the plugin closes the file. | 21 // deleted when the plugin closes the file. |
22 class WEBKIT_STORAGE_BROWSER_EXPORT OpenFileHandle { | 22 class WEBKIT_STORAGE_BROWSER_EXPORT OpenFileHandle { |
23 public: | 23 public: |
24 ~OpenFileHandle(); | 24 ~OpenFileHandle(); |
25 | 25 |
26 // Updates cached file size and consumes quota for that. | 26 // Updates cached file size and consumes quota for that. |
27 // This should be called for each modified file before calling RefreshQuota | 27 // This should be called for each modified file before calling |
28 // and file close. | 28 // QuotaReservation::RefreshQuota and before closing the file. |
29 // Returns updated base file size that should be used to measure quota | 29 void UpdateMaxWrittenOffset(int64 offset); |
30 // consumption by difference to this. | |
31 int64 UpdateMaxWrittenOffset(int64 offset); | |
32 | 30 |
33 int64 base_file_size() const; | 31 // Returns the estimated file size for the quota consumption calculation. |
| 32 // The client must consume its reserved quota when it writes data to the file |
| 33 // beyond the estimated file size. |
| 34 // The estimated file size is greater than or equal to actual file size after |
| 35 // all clients report their file usage, and is monotonically increasing over |
| 36 // OpenFileHandle object life cycle, so that client may cache the value. |
| 37 int64 GetEstimatedFileSize() const; |
34 | 38 |
35 private: | 39 private: |
36 friend class QuotaReservationBuffer; | 40 friend class QuotaReservationBuffer; |
37 | 41 |
38 OpenFileHandle(QuotaReservation* reservation, | 42 OpenFileHandle(QuotaReservation* reservation, |
39 OpenFileHandleContext* context); | 43 OpenFileHandleContext* context); |
40 | 44 |
41 scoped_refptr<QuotaReservation> reservation_; | 45 scoped_refptr<QuotaReservation> reservation_; |
42 scoped_refptr<OpenFileHandleContext> context_; | 46 scoped_refptr<OpenFileHandleContext> context_; |
43 | 47 |
44 base::SequenceChecker sequence_checker_; | 48 base::SequenceChecker sequence_checker_; |
45 | 49 |
46 DISALLOW_COPY_AND_ASSIGN(OpenFileHandle); | 50 DISALLOW_COPY_AND_ASSIGN(OpenFileHandle); |
47 }; | 51 }; |
48 | 52 |
49 } // namespace fileapi | 53 } // namespace fileapi |
50 | 54 |
51 #endif // WEBKIT_BROWSER_FILEAPI_QUOTA_OPEN_FILE_HANDLE_H_ | 55 #endif // WEBKIT_BROWSER_FILEAPI_QUOTA_OPEN_FILE_HANDLE_H_ |
OLD | NEW |