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

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

Issue 17507006: Disk cache v3 ref2 Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Incl IndexTable cl Created 7 years, 1 month 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/mapped_file.h ('k') | net/disk_cache/storage_block.h » ('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) 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/mapped_file.h" 5 #include "net/disk_cache/mapped_file.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "net/disk_cache/disk_cache.h" 10 #include "net/disk_cache/disk_cache.h"
(...skipping 10 matching lines...) Expand all
21 section_ = CreateFileMapping(platform_file(), NULL, PAGE_READWRITE, 0, 21 section_ = CreateFileMapping(platform_file(), NULL, PAGE_READWRITE, 0,
22 static_cast<DWORD>(size), NULL); 22 static_cast<DWORD>(size), NULL);
23 if (!section_) 23 if (!section_)
24 return NULL; 24 return NULL;
25 25
26 buffer_ = MapViewOfFile(section_, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, size); 26 buffer_ = MapViewOfFile(section_, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, size);
27 DCHECK(buffer_); 27 DCHECK(buffer_);
28 view_size_ = size; 28 view_size_ = size;
29 29
30 // Make sure we detect hardware failures reading the headers. 30 // Make sure we detect hardware failures reading the headers.
31 size_t temp_len = size ? size : 4096; 31 /*size_t temp_len = size ? size : 4096;
32 scoped_ptr<char[]> temp(new char[temp_len]); 32 scoped_ptr<char[]> temp(new char[temp_len]);
33 if (!Read(temp.get(), temp_len, 0)) 33 if (!Read(temp.get(), temp_len, 0))
34 return NULL; 34 return NULL;*/
35 35
36 return buffer_; 36 return buffer_;
37 } 37 }
38 38
39 bool MappedFile::InitNoMap(const base::FilePath& name) {
40 DCHECK(!init_);
41 if (init_ || !File::Init(name))
42 return false;
43
44 buffer_ = NULL;
45 section_ = NULL;
46 view_size_ = 0;
47 init_ = true;
48 return true;
49 }
50
39 MappedFile::~MappedFile() { 51 MappedFile::~MappedFile() {
40 if (!init_) 52 if (!init_)
41 return; 53 return;
42 54
43 if (buffer_) { 55 if (buffer_) {
44 BOOL ret = UnmapViewOfFile(buffer_); 56 BOOL ret = UnmapViewOfFile(buffer_);
45 DCHECK(ret); 57 DCHECK(ret);
46 } 58 }
47 59
48 if (section_) 60 if (section_)
49 CloseHandle(section_); 61 CloseHandle(section_);
50 } 62 }
51 63
52 void MappedFile::Flush() { 64 void MappedFile::Flush() {
53 } 65 }
54 66
55 } // namespace disk_cache 67 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/mapped_file.h ('k') | net/disk_cache/storage_block.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698