Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: net/disk_cache/mapped_file_posix.cc

Issue 6339012: More net/ method ordering. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More done while waiting for previous patch to clear Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/file_posix.cc ('k') | net/disk_cache/rankings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/mapped_file.h" 5 #include "net/disk_cache/mapped_file.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <sys/mman.h> 8 #include <sys/mman.h>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 14 matching lines...) Expand all
25 platform_file(), 0); 25 platform_file(), 0);
26 init_ = true; 26 init_ = true;
27 DCHECK(reinterpret_cast<intptr_t>(buffer_) != -1); 27 DCHECK(reinterpret_cast<intptr_t>(buffer_) != -1);
28 if (reinterpret_cast<intptr_t>(buffer_) == -1) 28 if (reinterpret_cast<intptr_t>(buffer_) == -1)
29 buffer_ = 0; 29 buffer_ = 0;
30 30
31 view_size_ = size; 31 view_size_ = size;
32 return buffer_; 32 return buffer_;
33 } 33 }
34 34
35 MappedFile::~MappedFile() {
36 if (!init_)
37 return;
38
39 if (buffer_) {
40 int ret = munmap(buffer_, view_size_);
41 DCHECK(0 == ret);
42 }
43 }
44
45 bool MappedFile::Load(const FileBlock* block) { 35 bool MappedFile::Load(const FileBlock* block) {
46 size_t offset = block->offset() + view_size_; 36 size_t offset = block->offset() + view_size_;
47 return Read(block->buffer(), block->size(), offset); 37 return Read(block->buffer(), block->size(), offset);
48 } 38 }
49 39
50 bool MappedFile::Store(const FileBlock* block) { 40 bool MappedFile::Store(const FileBlock* block) {
51 size_t offset = block->offset() + view_size_; 41 size_t offset = block->offset() + view_size_;
52 return Write(block->buffer(), block->size(), offset); 42 return Write(block->buffer(), block->size(), offset);
53 } 43 }
54 44
45 MappedFile::~MappedFile() {
46 if (!init_)
47 return;
48
49 if (buffer_) {
50 int ret = munmap(buffer_, view_size_);
51 DCHECK(0 == ret);
52 }
53 }
54
55 } // namespace disk_cache 55 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/file_posix.cc ('k') | net/disk_cache/rankings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698