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

Unified Diff: base/memory/shared_memory_win.cc

Issue 1351373002: Tweaks to SharedMemory to avoid CHECK when printing Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/printing/renderer/print_web_view_helper_pdf_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/shared_memory_win.cc
diff --git a/base/memory/shared_memory_win.cc b/base/memory/shared_memory_win.cc
index 5f706fe648598642584903f39a5aa40786acc88d..3c9f4b77d08710f407f2c6fb9406bf07454a1a5d 100644
--- a/base/memory/shared_memory_win.cc
+++ b/base/memory/shared_memory_win.cc
@@ -74,7 +74,7 @@ SharedMemory::~SharedMemory() {
// static
bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) {
- return handle != NULL;
+ return handle != NULL && handle != INVALID_HANDLE_VALUE;
rvargas (doing something else) 2015/09/18 22:36:25 <rant> I know I'm grumpy, but this pattern doesn't
}
// static
@@ -84,7 +84,7 @@ SharedMemoryHandle SharedMemory::NULLHandle() {
// static
void SharedMemory::CloseHandle(const SharedMemoryHandle& handle) {
- DCHECK(handle != NULL);
+ DCHECK(IsHandleValid(handle));
rvargas (doing something else) 2015/09/18 22:36:25 ScopedHandle closer(handle); <rant> receiving con
::CloseHandle(handle);
}
@@ -178,14 +178,14 @@ bool SharedMemory::Delete(const std::string& name) {
}
bool SharedMemory::Open(const std::string& name, bool read_only) {
- DCHECK(!mapped_file_);
+ DCHECK(!IsHandleValid(mapped_file_));
rvargas (doing something else) 2015/09/18 22:36:25 DCHECK(mapped_file_.Isvalid()); (+ making the mem
name_ = ASCIIToUTF16(name);
read_only_ = read_only;
mapped_file_ = OpenFileMapping(
read_only_ ? FILE_MAP_READ : FILE_MAP_READ | FILE_MAP_WRITE,
false, name_.empty() ? NULL : name_.c_str());
- if (mapped_file_ != NULL) {
+ if (IsHandleValid(mapped_file_)) {
// Note: size_ is not set in this case.
return true;
}
@@ -193,7 +193,7 @@ bool SharedMemory::Open(const std::string& name, bool read_only) {
}
bool SharedMemory::MapAt(off_t offset, size_t bytes) {
- if (mapped_file_ == NULL)
+ if (!IsHandleValid(mapped_file_))
return false;
if (bytes > static_cast<size_t>(std::numeric_limits<int>::max()))
@@ -259,7 +259,7 @@ bool SharedMemory::ShareToProcessCommon(ProcessHandle process,
void SharedMemory::Close() {
- if (mapped_file_ != NULL) {
+ if (IsHandleValid(mapped_file_)) {
CloseHandle(mapped_file_);
mapped_file_ = NULL;
}
« no previous file with comments | « no previous file | components/printing/renderer/print_web_view_helper_pdf_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698