| 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/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/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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 net::IOBuffer* buf, | 66 net::IOBuffer* buf, |
| 66 int buf_len, | 67 int buf_len, |
| 67 const SynchronousOperationCallback& callback); | 68 const SynchronousOperationCallback& callback); |
| 68 void WriteData(int index, | 69 void WriteData(int index, |
| 69 int offset, | 70 int offset, |
| 70 net::IOBuffer* buf, | 71 net::IOBuffer* buf, |
| 71 int buf_len, | 72 int buf_len, |
| 72 const SynchronousOperationCallback& callback, | 73 const SynchronousOperationCallback& callback, |
| 73 bool truncate); | 74 bool truncate); |
| 74 | 75 |
| 76 const base::FilePath& path() const { return path_; } |
| 75 std::string key() const { return key_; } | 77 std::string key() const { return key_; } |
| 76 base::Time last_used() const { return last_used_; } | 78 base::Time last_used() const { return last_used_; } |
| 77 base::Time last_modified() const { return last_modified_; } | 79 base::Time last_modified() const { return last_modified_; } |
| 78 int32 data_size(int index) const { return data_size_[index]; } | 80 int32 data_size(int index) const { return data_size_[index]; } |
| 79 | 81 |
| 80 private: | 82 private: |
| 81 static const int kIndexCount = 3; | |
| 82 | |
| 83 SimpleSynchronousEntry( | 83 SimpleSynchronousEntry( |
| 84 const scoped_refptr<base::TaskRunner>& callback_runner, | 84 const scoped_refptr<base::TaskRunner>& callback_runner, |
| 85 const base::FilePath& path, | 85 const base::FilePath& path, |
| 86 const std::string& key); | 86 const std::string& key); |
| 87 | 87 |
| 88 // Like Entry, the SimpleSynchronousEntry self releases when Close() is | 88 // Like Entry, the SimpleSynchronousEntry self releases when Close() is |
| 89 // called. | 89 // called. |
| 90 ~SimpleSynchronousEntry(); | 90 ~SimpleSynchronousEntry(); |
| 91 | 91 |
| 92 bool OpenOrCreateFiles(bool create); | 92 bool OpenOrCreateFiles(bool create); |
| 93 bool InitializeForOpen(); | 93 bool InitializeForOpen(); |
| 94 bool InitializeForCreate(); | 94 bool InitializeForCreate(); |
| 95 | 95 |
| 96 scoped_refptr<base::TaskRunner> callback_runner_; | 96 scoped_refptr<base::TaskRunner> callback_runner_; |
| 97 const base::FilePath path_; | 97 const base::FilePath path_; |
| 98 const std::string key_; | 98 const std::string key_; |
| 99 | 99 |
| 100 bool initialized_; | 100 bool initialized_; |
| 101 | 101 |
| 102 base::Time last_used_; | 102 base::Time last_used_; |
| 103 base::Time last_modified_; | 103 base::Time last_modified_; |
| 104 int32 data_size_[kIndexCount]; | 104 int32 data_size_[kSimpleEntryFileCount]; |
| 105 | 105 |
| 106 base::PlatformFile files_[kIndexCount]; | 106 base::PlatformFile files_[kSimpleEntryFileCount]; |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 } // namespace disk_cache | 109 } // namespace disk_cache |
| 110 | 110 |
| 111 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ | 111 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_SYNCHRONOUS_ENTRY_H_ |
| OLD | NEW |