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