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 3 // found in the LICENSE file. 4 5 #ifndef WEBKIT_BROWSER_FILEAPI_QUOTA_OPEN_FILE_HANDLE_H_ 6 #define WEBKIT_BROWSER_FILEAPI_QUOTA_OPEN_FILE_HANDLE_H_ 7 8 #include "base/basictypes.h" 9 #include "base/memory/ref_counted.h" 10 #include "base/memory/weak_ptr.h" 11 #include "webkit/browser/webkit_storage_browser_export.h" 12 13 namespace fileapi { 14 15 class QuotaReservation; 16 class OpenFileHandleContext; 17 class QuotaReservationBuffer; 18 19 // Represents an open file like a file descriptor. 20 // This should be alive while a consumer keeps a file opened and should be 21 // deleted when the plugin closes the file. 22 class WEBKIT_STORAGE_BROWSER_EXPORT OpenFileHandle { 23 public: 24 ~OpenFileHandle(); 25 26 // Updates cached file size and consumes quota for that. 27 // This should be called for each modified file before calling RefreshQuota 28 // and file close. 29 // Returns updated base file size that should be used to measure quota 30 // consumption by difference to this. 31 int64 UpdateMaxWrittenOffset(int64 offset); 32 33 int64 base_file_size() const; 34 35 private: 36 friend class QuotaReservationBuffer; 37 38 OpenFileHandle(QuotaReservation* reservation, 39 OpenFileHandleContext* context); 40 41 scoped_refptr<QuotaReservation> reservation_; 42 scoped_refptr<OpenFileHandleContext> context_; 43 44 base::SequenceChecker sequence_checker_; 45 46 DISALLOW_COPY_AND_ASSIGN(OpenFileHandle); 47 }; 48 49 } // namespace fileapi 50 51 #endif // WEBKIT_BROWSER_FILEAPI_QUOTA_OPEN_FILE_HANDLE_H_ 52