Include all dupe types (event when value is zero) in scan stats.
[chromium-blink-merge.git] / storage / browser / fileapi / quota / open_file_handle_context.h
blobcb3706491047be4372174fa58b31b013f9c8365d
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.
5 #ifndef STORAGE_BROWSER_FILEAPI_OPEN_FILE_HANDLE_CONTEXT_H_
6 #define STORAGE_BROWSER_FILEAPI_OPEN_FILE_HANDLE_CONTEXT_H_
8 #include <map>
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 "storage/browser/storage_browser_export.h"
15 #include "storage/common/fileapi/file_system_types.h"
16 #include "url/gurl.h"
18 namespace storage {
20 class QuotaReservationBuffer;
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
24 // handle.
25 // This class is usually manipulated only via OpenFileHandle.
26 class OpenFileHandleContext : public base::RefCounted<OpenFileHandleContext> {
27 public:
28 OpenFileHandleContext(const base::FilePath& platform_path,
29 QuotaReservationBuffer* reservation_buffer);
31 // Updates the max written offset and returns the amount of growth.
32 int64 UpdateMaxWrittenOffset(int64 offset);
34 void AddAppendModeWriteAmount(int64 amount);
36 const base::FilePath& platform_path() const {
37 return platform_path_;
40 int64 GetEstimatedFileSize() const;
41 int64 GetMaxWrittenOffset() const;
43 private:
44 friend class base::RefCounted<OpenFileHandleContext>;
45 virtual ~OpenFileHandleContext();
47 int64 initial_file_size_;
48 int64 maximum_written_offset_;
49 int64 append_mode_write_amount_;
50 base::FilePath platform_path_;
52 scoped_refptr<QuotaReservationBuffer> reservation_buffer_;
54 base::SequenceChecker sequence_checker_;
56 DISALLOW_COPY_AND_ASSIGN(OpenFileHandleContext);
59 } // namespace storage
61 #endif // STORAGE_BROWSER_FILEAPI_OPEN_FILE_HANDLE_CONTEXT_H_