diff options
author | tommi@google.com <tommi@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-14 16:52:11 +0000 |
---|---|---|
committer | tommi@google.com <tommi@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-14 16:52:11 +0000 |
commit | 3f85caafb239d5725ec85af9b8ce9f1b1de15770 (patch) | |
tree | dc5bdda66d8c915a1ae7b230c35130ab338ed703 /base/logging.h | |
parent | d92224288027cefbbd197bd9eed9080110aa9222 (diff) | |
download | chromium_src-3f85caafb239d5725ec85af9b8ce9f1b1de15770.zip chromium_src-3f85caafb239d5725ec85af9b8ce9f1b1de15770.tar.gz chromium_src-3f85caafb239d5725ec85af9b8ce9f1b1de15770.tar.bz2 |
Save and restore the value of GetLastError() when [D]LOG/[D]CHECK etc on Windows.
Also for log levels higher than INFO, the value of GLE is tagged onto the log message.
Review URL: http://codereview.chromium.org/73010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13667 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/logging.h')
-rw-r--r-- | base/logging.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/base/logging.h b/base/logging.h index b3bba0b..6a58cf3 100644 --- a/base/logging.h +++ b/base/logging.h @@ -540,6 +540,25 @@ class LogMessage { std::ostringstream stream_; size_t message_start_; // Offset of the start of the message (past prefix // info). +#if defined(OS_WIN) + // Stores the current value of GetLastError in the constructor and restores + // it in the destructor by calling SetLastError. + // This is useful since the LogMessage class uses a lot of Win32 calls + // that will lose the value of GLE and the code that called the log function + // will have lost the thread error value when the log call returns. + class SaveLastError { + public: + SaveLastError(); + ~SaveLastError(); + + unsigned long get_error() const { return last_error_; } + + protected: + unsigned long last_error_; + }; + + SaveLastError last_error_; +#endif DISALLOW_COPY_AND_ASSIGN(LogMessage); }; |