| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ | 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ |
| 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ | 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
| 14 #include "base/task_runner.h" | 14 #include "base/task_runner.h" |
| 15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
| 17 #include "net/disk_cache/simple/simple_disk_format.h" |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 class SingleThreadTaskRunner; | 20 class SingleThreadTaskRunner; |
| 20 } | 21 } |
| 21 | 22 |
| 22 namespace net { | 23 namespace net { |
| 23 class IOBuffer; | 24 class IOBuffer; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace disk_cache { | 27 namespace disk_cache { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 net::IOBuffer* buf, | 65 net::IOBuffer* buf, |
| 65 int buf_len, | 66 int buf_len, |
| 66 const SynchronousEntryCallback& callback); | 67 const SynchronousEntryCallback& callback); |
| 67 void WriteData(int index, | 68 void WriteData(int index, |
| 68 int offset, | 69 int offset, |
| 69 net::IOBuffer* buf, | 70 net::IOBuffer* buf, |
| 70 int buf_len, | 71 int buf_len, |
| 71 const SynchronousEntryCallback& callback, | 72 const SynchronousEntryCallback& callback, |
| 72 bool truncate); | 73 bool truncate); |
| 73 | 74 |
| 75 const base::FilePath& path() const { return path_; } |
| 74 std::string key() const { return key_; } | 76 std::string key() const { return key_; } |
| 75 base::Time last_used() const { return last_used_; } | 77 base::Time last_used() const { return last_used_; } |
| 76 base::Time last_modified() const { return last_modified_; } | 78 base::Time last_modified() const { return last_modified_; } |
| 77 int32 data_size(int index) const { return data_size_[index]; } | 79 int32 data_size(int index) const { return data_size_[index]; } |
| 78 | 80 |
| 79 private: | 81 private: |
| 80 static const int kIndexCount = 3; | |
| 81 | |
| 82 struct EntryStatus { | 82 struct EntryStatus { |
| 83 enum Mode { | 83 enum Mode { |
| 84 ENTRY_UNINITIALIZED, | 84 ENTRY_UNINITIALIZED, |
| 85 ENTRY_READER, | 85 ENTRY_READER, |
| 86 ENTRY_WRITER, | 86 ENTRY_WRITER, |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 EntryStatus(); | 89 EntryStatus(); |
| 90 | 90 |
| 91 Mode mode; | 91 Mode mode; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 106 bool InitializeForCreate(); | 106 bool InitializeForCreate(); |
| 107 | 107 |
| 108 scoped_refptr<base::TaskRunner> callback_runner_; | 108 scoped_refptr<base::TaskRunner> callback_runner_; |
| 109 const FilePath path_; | 109 const FilePath path_; |
| 110 const std::string key_; | 110 const std::string key_; |
| 111 | 111 |
| 112 bool initialized_; | 112 bool initialized_; |
| 113 | 113 |
| 114 base::Time last_used_; | 114 base::Time last_used_; |
| 115 base::Time last_modified_; | 115 base::Time last_modified_; |
| 116 int32 data_size_[kIndexCount]; | 116 int32 data_size_[kSimpleEntryFileCount]; |
| 117 | 117 |
| 118 base::PlatformFile files_[kIndexCount]; | 118 base::PlatformFile files_[kSimpleEntryFileCount]; |
| 119 EntryStatus status_[kIndexCount]; | 119 EntryStatus status_[kSimpleEntryFileCount]; |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 } // namespace disk_cache | 122 } // namespace disk_cache |
| 123 | 123 |
| 124 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ | 124 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ |
| OLD | NEW |