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

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

Issue 1894733002: Change scoped_ptr to std::unique_ptr in //net/disk_cache. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « net/disk_cache/blockfile/mapped_file.cc ('k') | net/disk_cache/blockfile/mapped_file_win.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) 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/blockfile/mapped_file.h" 5 #include "net/disk_cache/blockfile/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/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 13 matching lines...) Expand all
24 24
25 buffer_ = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, 25 buffer_ = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
26 platform_file(), 0); 26 platform_file(), 0);
27 init_ = true; 27 init_ = true;
28 view_size_ = size; 28 view_size_ = size;
29 DPLOG_IF(FATAL, buffer_ == MAP_FAILED) << "Failed to mmap " << name.value(); 29 DPLOG_IF(FATAL, buffer_ == MAP_FAILED) << "Failed to mmap " << name.value();
30 if (buffer_ == MAP_FAILED) 30 if (buffer_ == MAP_FAILED)
31 buffer_ = 0; 31 buffer_ = 0;
32 32
33 // Make sure we detect hardware failures reading the headers. 33 // Make sure we detect hardware failures reading the headers.
34 scoped_ptr<char[]> temp(new char[temp_len]); 34 std::unique_ptr<char[]> temp(new char[temp_len]);
35 if (!Read(temp.get(), temp_len, 0)) 35 if (!Read(temp.get(), temp_len, 0))
36 return NULL; 36 return NULL;
37 37
38 return buffer_; 38 return buffer_;
39 } 39 }
40 40
41 void MappedFile::Flush() { 41 void MappedFile::Flush() {
42 } 42 }
43 43
44 MappedFile::~MappedFile() { 44 MappedFile::~MappedFile() {
45 if (!init_) 45 if (!init_)
46 return; 46 return;
47 47
48 if (buffer_) { 48 if (buffer_) {
49 int ret = munmap(buffer_, view_size_); 49 int ret = munmap(buffer_, view_size_);
50 DCHECK_EQ(0, ret); 50 DCHECK_EQ(0, ret);
51 } 51 }
52 } 52 }
53 53
54 } // namespace disk_cache 54 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/mapped_file.cc ('k') | net/disk_cache/blockfile/mapped_file_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698