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

Side by Side Diff: base/files/memory_mapped_file_posix.cc

Issue 430583005: Make VEA test support videos with different coded size and visible size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address wucheng's review comments Created 6 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/files/memory_mapped_file.h" 5 #include "base/files/memory_mapped_file.h"
6 6
7 #include <sys/mman.h> 7 #include <sys/mman.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 return false; 55 return false;
56 } 56 }
57 57
58 map_start = static_cast<off_t>(aligned_start); 58 map_start = static_cast<off_t>(aligned_start);
59 map_size = static_cast<size_t>(aligned_size); 59 map_size = static_cast<size_t>(aligned_size);
60 length_ = static_cast<size_t>(region.size); 60 length_ = static_cast<size_t>(region.size);
61 } 61 }
62 62
63 data_ = static_cast<uint8*>(mmap(NULL, 63 data_ = static_cast<uint8*>(mmap(NULL,
64 map_size, 64 map_size,
65 PROT_READ, 65 PROT_READ | PROT_WRITE,
66 MAP_SHARED, 66 MAP_SHARED,
67 file_.GetPlatformFile(), 67 file_.GetPlatformFile(),
68 map_start)); 68 map_start));
69 if (data_ == MAP_FAILED) { 69 if (data_ == MAP_FAILED) {
70 DPLOG(ERROR) << "mmap " << file_.GetPlatformFile(); 70 DPLOG(ERROR) << "mmap " << file_.GetPlatformFile();
71 return false; 71 return false;
72 } 72 }
73 73
74 data_ += data_offset; 74 data_ += data_offset;
75 return true; 75 return true;
76 } 76 }
77 77
78 void MemoryMappedFile::CloseHandles() { 78 void MemoryMappedFile::CloseHandles() {
79 ThreadRestrictions::AssertIOAllowed(); 79 ThreadRestrictions::AssertIOAllowed();
80 80
81 if (data_ != NULL) 81 if (data_ != NULL)
82 munmap(data_, length_); 82 munmap(data_, length_);
83 file_.Close(); 83 file_.Close();
84 84
85 data_ = NULL; 85 data_ = NULL;
86 length_ = 0; 86 length_ = 0;
87 } 87 }
88 88
89 } // namespace base 89 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698