OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/flash/storage.h" | 5 #include "net/disk_cache/flash/storage.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 #endif | 36 #endif |
37 | 37 |
38 return true; | 38 return true; |
39 } | 39 } |
40 | 40 |
41 Storage::~Storage() { | 41 Storage::~Storage() { |
42 base::ClosePlatformFile(file_); | 42 base::ClosePlatformFile(file_); |
43 } | 43 } |
44 | 44 |
45 bool Storage::Read(void* buffer, int32 size, int32 offset) { | 45 bool Storage::Read(void* buffer, int32 size, int32 offset) { |
46 DCHECK(buffer); | |
47 DCHECK(offset >= 0 && offset + size <= size_); | 46 DCHECK(offset >= 0 && offset + size <= size_); |
48 | 47 |
49 int rv = base::ReadPlatformFile(file_, offset, static_cast<char*>(buffer), | 48 int rv = base::ReadPlatformFile(file_, offset, static_cast<char*>(buffer), |
50 size); | 49 size); |
51 return rv == size; | 50 return rv == size; |
52 } | 51 } |
53 | 52 |
54 bool Storage::Write(const void* buffer, int32 size, int32 offset) { | 53 bool Storage::Write(const void* buffer, int32 size, int32 offset) { |
55 DCHECK(buffer); | |
56 DCHECK(offset >= 0 && offset + size <= size_); | 54 DCHECK(offset >= 0 && offset + size <= size_); |
57 | 55 |
58 int rv = base::WritePlatformFile(file_, offset, | 56 int rv = base::WritePlatformFile(file_, offset, |
59 static_cast<const char*>(buffer), size); | 57 static_cast<const char*>(buffer), size); |
60 return rv == size; | 58 return rv == size; |
61 } | 59 } |
62 | 60 |
63 } // namespace disk_cache | 61 } // namespace disk_cache |
OLD | NEW |