Commit b427af26 authored by Joshua Peraza's avatar Joshua Peraza Committed by Commit Bot

un-internalize ScopedClearLastError

Crashpad began using ScopedClearErrno in
https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2119645
but chromium's ScopedClearErrno was replaced with
ScopedClearLastError. mini_chromium was updated to
mirror chromium's ScopedClearLastError in
https://chromium-review.googlesource.com/c/chromium/mini_chromium/+/2141050

Change-Id: I562e25c4033a3c892a6982e3a827a9ee821d8d68
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2142144
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: default avatarEric Roman <eroman@chromium.org>
Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758621}
parent 396d70f9
......@@ -926,7 +926,7 @@ class BASE_EXPORT LogMessage {
// 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.
base::internal::ScopedClearLastError last_error_;
base::ScopedClearLastError last_error_;
DISALLOW_COPY_AND_ASSIGN(LogMessage);
};
......
// Copyright (c) 2018 The Chromium Authors. All rights reserved.
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
......@@ -12,7 +12,6 @@
#include "build/build_config.h"
namespace base {
namespace internal {
// ScopedClearLastError stores and resets the value of thread local error codes
// (errno, GetLastError()), and restores them in the destructor. This is useful
......@@ -41,7 +40,7 @@ class BASE_EXPORT ScopedClearLastError : public ScopedClearLastErrorBase {
~ScopedClearLastError();
private:
unsigned int last_system_error_;
const unsigned long last_system_error_;
DISALLOW_COPY_AND_ASSIGN(ScopedClearLastError);
};
......@@ -52,7 +51,6 @@ using ScopedClearLastError = ScopedClearLastErrorBase;
#endif // defined(OS_WIN)
} // namespace internal
} // namespace base
#endif // BASE_SCOPED_CLEAR_LAST_ERROR_H_
......@@ -13,7 +13,6 @@
#endif // defined(OS_WIN)
namespace base {
namespace internal {
TEST(ScopedClearLastError, TestNoError) {
errno = 1;
......@@ -55,5 +54,4 @@ TEST(ScopedClearLastError, TestErrorWin) {
#endif // defined(OS_WIN)
} // namespace internal
} // namespace base
// Copyright (c) 2018 The Chromium Authors. All rights reserved.
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
......@@ -7,16 +7,14 @@
#include <windows.h>
namespace base {
namespace internal {
ScopedClearLastError::ScopedClearLastError()
: last_system_error_(::GetLastError()) {
::SetLastError(0);
: ScopedClearLastErrorBase(), last_system_error_(GetLastError()) {
SetLastError(0);
}
ScopedClearLastError::~ScopedClearLastError() {
::SetLastError(last_system_error_);
SetLastError(last_system_error_);
}
} // namespace internal
} // namespace base
......@@ -62,7 +62,7 @@ static void StringAppendVT(std::basic_string<CharT>* dst,
va_list ap_copy;
va_copy(ap_copy, ap);
base::internal::ScopedClearLastError last_error;
base::ScopedClearLastError last_error;
int result = vsnprintfT(stack_buf, base::size(stack_buf), format, ap_copy);
va_end(ap_copy);
......
......@@ -70,7 +70,7 @@ UncheckedScopedBlockingCall::UncheckedScopedBlockingCall(
UncheckedScopedBlockingCall::~UncheckedScopedBlockingCall() {
// TLS affects result of GetLastError() on Windows. ScopedClearLastError
// prevents side effect.
base::internal::ScopedClearLastError save_last_error;
base::ScopedClearLastError save_last_error;
DCHECK_EQ(this, tls_last_scoped_blocking_call.Get().Get());
tls_last_scoped_blocking_call.Get().Set(previous_scoped_blocking_call_);
if (blocking_observer_ && !previous_scoped_blocking_call_)
......
......@@ -1155,7 +1155,7 @@ TEST_F(DscpManagerTest, SocketReAddedOnRecreateHandle) {
.WillOnce(Return(true));
dscp_manager_->Set(DSCP_CS7);
auto error = std::make_unique<base::internal::ScopedClearLastError>();
auto error = std::make_unique<base::ScopedClearLastError>();
::SetLastError(ERROR_DEVICE_REINITIALIZATION_NEEDED);
EXPECT_CALL(api_, AddSocketToFlow(_, _, _, _, _, _)).WillOnce(Return(false));
EXPECT_CALL(api_, SetFlow(_, _, _, _, _, _, _)).Times(0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment