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_OPEN_FILE_HANDLE_CONTEXT_H_ | 5 #ifndef WEBKIT_BROWSER_FILEAPI_OPEN_FILE_HANDLE_CONTEXT_H_ |
6 #define WEBKIT_BROWSER_FILEAPI_OPEN_FILE_HANDLE_CONTEXT_H_ | 6 #define WEBKIT_BROWSER_FILEAPI_OPEN_FILE_HANDLE_CONTEXT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 // This class represents a underlying file of a managed FileSystem file. | 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 | 24 // The instance keeps alive while at least one consumer keeps an open file |
25 // handle. | 25 // handle. |
26 // This class is usually manipulated only via OpenFileHandle. | 26 // This class is usually manipulated only via OpenFileHandle. |
27 class OpenFileHandleContext : public base::RefCounted<OpenFileHandleContext> { | 27 class OpenFileHandleContext : public base::RefCounted<OpenFileHandleContext> { |
28 public: | 28 public: |
29 OpenFileHandleContext(const base::FilePath& platform_path, | 29 OpenFileHandleContext(const base::FilePath& platform_path, |
30 QuotaReservationBuffer* reservation_buffer); | 30 QuotaReservationBuffer* reservation_buffer); |
31 | 31 |
32 void UpdateMaxWrittenOffset(int64 offset, | 32 // Updates the max written offset and returns the amount of growth. |
33 int64* new_file_size, | 33 int64 UpdateMaxWrittenOffset(int64 offset); |
34 int64* growth); | |
35 | 34 |
36 const base::FilePath& platform_path() const { | 35 const base::FilePath& platform_path() const { |
37 return platform_path_; | 36 return platform_path_; |
38 } | 37 } |
39 | 38 |
40 int64 base_file_size() const { return maximum_written_offset_; } | 39 int64 GetEstimatedFileSize() const; |
41 | 40 |
42 private: | 41 private: |
43 friend class base::RefCounted<OpenFileHandleContext>; | 42 friend class base::RefCounted<OpenFileHandleContext>; |
44 virtual ~OpenFileHandleContext(); | 43 virtual ~OpenFileHandleContext(); |
45 | 44 |
46 int64 initial_file_size_; | 45 int64 initial_file_size_; |
47 int64 maximum_written_offset_; | 46 int64 maximum_written_offset_; |
48 base::FilePath platform_path_; | 47 base::FilePath platform_path_; |
49 | 48 |
50 scoped_refptr<QuotaReservationBuffer> reservation_buffer_; | 49 scoped_refptr<QuotaReservationBuffer> reservation_buffer_; |
51 | 50 |
52 base::SequenceChecker sequence_checker_; | 51 base::SequenceChecker sequence_checker_; |
53 | 52 |
54 DISALLOW_COPY_AND_ASSIGN(OpenFileHandleContext); | 53 DISALLOW_COPY_AND_ASSIGN(OpenFileHandleContext); |
55 }; | 54 }; |
56 | 55 |
57 } // namespace fileapi | 56 } // namespace fileapi |
58 | 57 |
59 #endif // WEBKIT_BROWSER_FILEAPI_OPEN_FILE_HANDLE_CONTEXT_H_ | 58 #endif // WEBKIT_BROWSER_FILEAPI_OPEN_FILE_HANDLE_CONTEXT_H_ |
OLD | NEW |