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

Side by Side Diff: base/memory/shared_memory_win.cc

Issue 2015983002: Revert of base: Add debugging to track down CreateFileMapping() errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/memory/shared_memory.h" 5 #include "base/memory/shared_memory.h"
6 6
7 #include <aclapi.h> 7 #include <aclapi.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include "base/debug/alias.h"
12 #include "base/debug/dump_without_crashing.h"
13 #include "base/logging.h" 11 #include "base/logging.h"
14 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
15 #include "base/rand_util.h" 13 #include "base/rand_util.h"
16 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
18 16
19 namespace { 17 namespace {
20 18
21 // Errors that can occur during Shared Memory construction. 19 // Errors that can occur during Shared Memory construction.
22 // These match tools/metrics/histograms/histograms.xml. 20 // These match tools/metrics/histograms/histograms.xml.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // 101 //
104 // By removing all access control permissions of a file mapping immediately 102 // By removing all access control permissions of a file mapping immediately
105 // after creation, ::DuplicateHandle() effectively only copies the file 103 // after creation, ::DuplicateHandle() effectively only copies the file
106 // permissions. 104 // permissions.
107 HANDLE CreateFileMappingWithReducedPermissions(SECURITY_ATTRIBUTES* sa, 105 HANDLE CreateFileMappingWithReducedPermissions(SECURITY_ATTRIBUTES* sa,
108 size_t rounded_size, 106 size_t rounded_size,
109 LPCWSTR name) { 107 LPCWSTR name) {
110 HANDLE h = CreateFileMapping(INVALID_HANDLE_VALUE, sa, PAGE_READWRITE, 0, 108 HANDLE h = CreateFileMapping(INVALID_HANDLE_VALUE, sa, PAGE_READWRITE, 0,
111 static_cast<DWORD>(rounded_size), name); 109 static_cast<DWORD>(rounded_size), name);
112 if (!h) { 110 if (!h) {
113 // Debugging to help track down https://crbug.com/585013
114 DWORD last_error = ::GetLastError();
115 base::debug::Alias(&last_error);
116 base::debug::DumpWithoutCrashing();
117
118 LogError(CREATE_FILE_MAPPING_FAILURE); 111 LogError(CREATE_FILE_MAPPING_FAILURE);
119 return nullptr; 112 return nullptr;
120 } 113 }
121 114
122 HANDLE h2; 115 HANDLE h2;
123 BOOL success = ::DuplicateHandle( 116 BOOL success = ::DuplicateHandle(
124 GetCurrentProcess(), h, GetCurrentProcess(), &h2, 117 GetCurrentProcess(), h, GetCurrentProcess(), &h2,
125 FILE_MAP_READ | FILE_MAP_WRITE | SECTION_QUERY, FALSE, 0); 118 FILE_MAP_READ | FILE_MAP_WRITE | SECTION_QUERY, FALSE, 0);
126 BOOL rv = ::CloseHandle(h); 119 BOOL rv = ::CloseHandle(h);
127 DCHECK(rv); 120 DCHECK(rv);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 ::CloseHandle(mapped_file_); 383 ::CloseHandle(mapped_file_);
391 mapped_file_ = NULL; 384 mapped_file_ = NULL;
392 } 385 }
393 } 386 }
394 387
395 SharedMemoryHandle SharedMemory::handle() const { 388 SharedMemoryHandle SharedMemory::handle() const {
396 return SharedMemoryHandle(mapped_file_, base::GetCurrentProcId()); 389 return SharedMemoryHandle(mapped_file_, base::GetCurrentProcId());
397 } 390 }
398 391
399 } // namespace base 392 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698