OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include "net/disk_cache/file_lock.h" | 5 #include "net/disk_cache/file_lock.h" |
6 | 6 |
7 namespace disk_cache { | 7 namespace disk_cache { |
8 | 8 |
9 FileLock::FileLock(BlockFileHeader* header) { | 9 FileLock::FileLock(BlockFileHeader* header) { |
10 updating_ = &header->updating; | 10 updating_ = &header->updating; |
11 (*updating_)++; | 11 (*updating_)++; |
12 acquired_ = true; | 12 acquired_ = true; |
13 } | 13 } |
14 | 14 |
| 15 FileLock::~FileLock() { |
| 16 Unlock(); |
| 17 } |
| 18 |
15 void FileLock::Lock() { | 19 void FileLock::Lock() { |
16 if (acquired_) | 20 if (acquired_) |
17 return; | 21 return; |
18 (*updating_)++; | 22 (*updating_)++; |
19 } | 23 } |
20 | 24 |
21 void FileLock::Unlock() { | 25 void FileLock::Unlock() { |
22 if (!acquired_) | 26 if (!acquired_) |
23 return; | 27 return; |
24 (*updating_)--; | 28 (*updating_)--; |
25 } | 29 } |
26 | 30 |
27 } // namespace disk_cache | 31 } // namespace disk_cache |
OLD | NEW |