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_OPEN_FILE_HANDLE_CONTEXT_H_ 6 #define WEBKIT_BROWSER_FILEAPI_OPEN_FILE_HANDLE_CONTEXT_H_ 7 8 #include <map> 9 10 #include "base/basictypes.h" 11 #include "base/files/file_path.h" 12 #include "base/memory/ref_counted.h" 13 #include "base/memory/weak_ptr.h" 14 #include "base/platform_file.h" 15 #include "url/gurl.h" 16 #include "webkit/browser/webkit_storage_browser_export.h" 17 #include "webkit/common/fileapi/file_system_types.h" 18 19 namespace fileapi { 20 21 class QuotaReservationBuffer; 22 23 // This class represents a underlying file of a managed FileSystem file. 24 // The instance keeps alive while at least one consumer keeps an open file 25 // handle. 26 // This class is usually manipulated only via OpenFileHandle. 27 class OpenFileHandleContext : public base::RefCounted<OpenFileHandleContext> { 28 public: 29 OpenFileHandleContext(const base::FilePath& platform_path, 30 QuotaReservationBuffer* reservation_buffer); 31 32 void UpdateMaxWrittenOffset(int64 offset, 33 int64* new_file_size, 34 int64* growth); 35 platform_path()36 const base::FilePath& platform_path() const { 37 return platform_path_; 38 } 39 base_file_size()40 int64 base_file_size() const { return maximum_written_offset_; } 41 42 private: 43 friend class base::RefCounted<OpenFileHandleContext>; 44 virtual ~OpenFileHandleContext(); 45 46 int64 initial_file_size_; 47 int64 maximum_written_offset_; 48 base::FilePath platform_path_; 49 50 scoped_refptr<QuotaReservationBuffer> reservation_buffer_; 51 52 base::SequenceChecker sequence_checker_; 53 54 DISALLOW_COPY_AND_ASSIGN(OpenFileHandleContext); 55 }; 56 57 } // namespace fileapi 58 59 #endif // WEBKIT_BROWSER_FILEAPI_OPEN_FILE_HANDLE_CONTEXT_H_ 60