Get GenericScopedHandle::Set to preserve LastError code
commit84f30fe06877193d39bb2cb9fe345c2e12e695b3
authorbrucedawson <brucedawson@chromium.org>
Fri, 11 Sep 2015 03:08:29 +0000 (10 20:08 -0700)
committerCommit bot <commit-bot@chromium.org>
Fri, 11 Sep 2015 03:09:45 +0000 (11 03:09 +0000)
treecefa84bc8703e7c4ee6aaf70e465ede8a3e8129e
parent34ab19d59ff4a5bc098d90eb7c4fc76afec568ef
Get GenericScopedHandle::Set to preserve LastError code

Code like this is elegant and clean and common in Chrome:

  event_.Set(CreateEvent(NULL, FALSE, FALSE, wname.c_str()));
  if (event_.Get() && GetLastError() != ERROR_ALREADY_EXISTS) {

However it will behave incorrectly if event_.Set() zeroes out the
Windows LastError code, which VC++ 2015 frequently does. This change
avoids that.

R=rvargas@chromium.org
BUG=528394,529981,440500

Review URL: https://codereview.chromium.org/1320673016

Cr-Commit-Position: refs/heads/master@{#348324}
base/BUILD.gn
base/base.gyp
base/win/scoped_handle.h
base/win/scoped_handle_unittest.cc [new file with mode: 0644]