Skip to content

Commit

Permalink
Revert "Remove base/scoped_handle_win.h stub and fix up all callers t…
Browse files Browse the repository at this point in the history
…o use the new location and namespace."

This reverts r 70795, it broke the build.

TBR=vandebo

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70802 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
thakis@chromium.org committed Jan 7, 2011
1 parent ff81c19 commit 15d9694
Show file tree
Hide file tree
Showing 57 changed files with 245 additions and 269 deletions.
3 changes: 2 additions & 1 deletion app/win/win_util.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2010 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.

Expand All @@ -17,6 +17,7 @@
#include "base/i18n/rtl.h"
#include "base/logging.h"
#include "base/scoped_handle.h"
#include "base/scoped_handle_win.h"
#include "base/string_util.h"
#include "base/win/scoped_gdi_object.h"
#include "base/win/scoped_hdc.h"
Expand Down
13 changes: 5 additions & 8 deletions base/file_util_unittest.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2010 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.

Expand All @@ -19,17 +19,14 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/path_service.h"
#include "base/scoped_handle.h"
#include "base/scoped_temp_dir.h"
#include "base/threading/platform_thread.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"

#if defined(OS_WIN)
#include "base/win/scoped_handle.h"
#endif

// This macro helps avoid wrapped lines in the test structs.
#define FPL(x) FILE_PATH_LITERAL(x)

Expand Down Expand Up @@ -474,7 +471,7 @@ TEST_F(FileUtilTest, NormalizeFilePathReparsePoints) {

FilePath to_sub_a = base_b.Append(FPL("to_sub_a"));
ASSERT_TRUE(file_util::CreateDirectory(to_sub_a));
base::win::ScopedHandle reparse_to_sub_a(
ScopedHandle reparse_to_sub_a(
::CreateFile(to_sub_a.value().c_str(),
FILE_ALL_ACCESS,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
Expand All @@ -487,7 +484,7 @@ TEST_F(FileUtilTest, NormalizeFilePathReparsePoints) {

FilePath to_base_b = base_b.Append(FPL("to_base_b"));
ASSERT_TRUE(file_util::CreateDirectory(to_base_b));
base::win::ScopedHandle reparse_to_base_b(
ScopedHandle reparse_to_base_b(
::CreateFile(to_base_b.value().c_str(),
FILE_ALL_ACCESS,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
Expand All @@ -500,7 +497,7 @@ TEST_F(FileUtilTest, NormalizeFilePathReparsePoints) {

FilePath to_sub_long = base_b.Append(FPL("to_sub_long"));
ASSERT_TRUE(file_util::CreateDirectory(to_sub_long));
base::win::ScopedHandle reparse_to_sub_long(
ScopedHandle reparse_to_sub_long(
::CreateFile(to_sub_long.value().c_str(),
FILE_ALL_ACCESS,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
Expand Down
30 changes: 14 additions & 16 deletions base/message_loop_unittest.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2010 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.

Expand All @@ -15,7 +15,7 @@

#if defined(OS_WIN)
#include "base/message_pump_win.h"
#include "base/win/scoped_handle.h"
#include "base/scoped_handle.h"
#endif
#if defined(OS_POSIX)
#include "base/message_pump_libevent.h"
Expand Down Expand Up @@ -937,7 +937,7 @@ void RunTest_RecursiveDenial2(MessageLoop::Type message_loop_type) {
options.message_loop_type = message_loop_type;
ASSERT_EQ(true, worker.StartWithOptions(options));
TaskList order;
base::win::ScopedHandle event(CreateEvent(NULL, FALSE, FALSE, NULL));
ScopedHandle event(CreateEvent(NULL, FALSE, FALSE, NULL));
worker.message_loop()->PostTask(FROM_HERE,
new Recursive2Tasks(MessageLoop::current(),
event,
Expand Down Expand Up @@ -980,7 +980,7 @@ void RunTest_RecursiveSupport2(MessageLoop::Type message_loop_type) {
options.message_loop_type = message_loop_type;
ASSERT_EQ(true, worker.StartWithOptions(options));
TaskList order;
base::win::ScopedHandle event(CreateEvent(NULL, FALSE, FALSE, NULL));
ScopedHandle event(CreateEvent(NULL, FALSE, FALSE, NULL));
worker.message_loop()->PostTask(FROM_HERE,
new Recursive2Tasks(MessageLoop::current(),
event,
Expand Down Expand Up @@ -1187,7 +1187,7 @@ class TestIOHandler : public MessageLoopForIO::IOHandler {
char buffer_[48];
MessageLoopForIO::IOContext context_;
HANDLE signal_;
base::win::ScopedHandle file_;
ScopedHandle file_;
bool wait_;
};

Expand Down Expand Up @@ -1235,12 +1235,12 @@ class IOHandlerTask : public Task {
};

void RunTest_IOHandler() {
base::win::ScopedHandle callback_called(CreateEvent(NULL, TRUE, FALSE, NULL));
ScopedHandle callback_called(CreateEvent(NULL, TRUE, FALSE, NULL));
ASSERT_TRUE(callback_called.IsValid());

const wchar_t* kPipeName = L"\\\\.\\pipe\\iohandler_pipe";
base::win::ScopedHandle server(
CreateNamedPipe(kPipeName, PIPE_ACCESS_OUTBOUND, 0, 1, 0, 0, 0, NULL));
ScopedHandle server(CreateNamedPipe(kPipeName, PIPE_ACCESS_OUTBOUND, 0, 1,
0, 0, 0, NULL));
ASSERT_TRUE(server.IsValid());

Thread thread("IOHandler test");
Expand All @@ -1267,19 +1267,17 @@ void RunTest_IOHandler() {
}

void RunTest_WaitForIO() {
base::win::ScopedHandle callback1_called(
CreateEvent(NULL, TRUE, FALSE, NULL));
base::win::ScopedHandle callback2_called(
CreateEvent(NULL, TRUE, FALSE, NULL));
ScopedHandle callback1_called(CreateEvent(NULL, TRUE, FALSE, NULL));
ScopedHandle callback2_called(CreateEvent(NULL, TRUE, FALSE, NULL));
ASSERT_TRUE(callback1_called.IsValid());
ASSERT_TRUE(callback2_called.IsValid());

const wchar_t* kPipeName1 = L"\\\\.\\pipe\\iohandler_pipe1";
const wchar_t* kPipeName2 = L"\\\\.\\pipe\\iohandler_pipe2";
base::win::ScopedHandle server1(
CreateNamedPipe(kPipeName1, PIPE_ACCESS_OUTBOUND, 0, 1, 0, 0, 0, NULL));
base::win::ScopedHandle server2(
CreateNamedPipe(kPipeName2, PIPE_ACCESS_OUTBOUND, 0, 1, 0, 0, 0, NULL));
ScopedHandle server1(CreateNamedPipe(kPipeName1, PIPE_ACCESS_OUTBOUND, 0, 1,
0, 0, 0, NULL));
ScopedHandle server2(CreateNamedPipe(kPipeName2, PIPE_ACCESS_OUTBOUND, 0, 1,
0, 0, 0, NULL));
ASSERT_TRUE(server1.IsValid());
ASSERT_TRUE(server2.IsValid());

Expand Down
6 changes: 3 additions & 3 deletions base/message_pump_win.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2006-2008 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.

Expand All @@ -13,8 +13,8 @@
#include "base/basictypes.h"
#include "base/message_pump.h"
#include "base/observer_list.h"
#include "base/scoped_handle.h"
#include "base/time.h"
#include "base/win/scoped_handle.h"

namespace base {

Expand Down Expand Up @@ -356,7 +356,7 @@ class MessagePumpForIO : public MessagePumpWin {
void DidProcessIOEvent();

// The completion port associated with this thread.
win::ScopedHandle port_;
ScopedHandle port_;
// This list will be empty almost always. It stores IO completions that have
// not been delivered yet because somebody was doing cleanup.
std::list<IOItem> completed_io_;
Expand Down
6 changes: 5 additions & 1 deletion base/scoped_handle.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2010 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.

Expand All @@ -10,6 +10,10 @@

#include "base/basictypes.h"

#if defined(OS_WIN)
#include "base/scoped_handle_win.h"
#endif

class ScopedStdioHandle {
public:
ScopedStdioHandle()
Expand Down
9 changes: 9 additions & 0 deletions base/scoped_handle_win.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) 2010 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.

// TODO(brettw) remove this file when all callers are converted to using the
// new location/namespace
#include "base/win/scoped_handle.h"

using base::win::ScopedHandle;
6 changes: 3 additions & 3 deletions base/test/test_file_util_win.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2008 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.

Expand All @@ -12,7 +12,7 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/win/scoped_handle.h"
#include "base/scoped_handle.h"
#include "base/threading/platform_thread.h"

namespace file_util {
Expand All @@ -39,7 +39,7 @@ bool DieFileDie(const FilePath& file, bool recurse) {

bool EvictFileFromSystemCache(const FilePath& file) {
// Request exclusive access to the file and overwrite it with no buffering.
base::win::ScopedHandle file_handle(
ScopedHandle file_handle(
CreateFile(file.value().c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL));
if (!file_handle)
Expand Down
16 changes: 7 additions & 9 deletions base/win/event_trace_consumer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@
//
// Unit tests for event trace consumer_ base class.
#include "base/win/event_trace_consumer.h"

#include <list>

#include "base/basictypes.h"
#include "base/win/event_trace_controller.h"
#include "base/win/event_trace_provider.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/win/event_trace_controller.h"
#include "base/win/event_trace_provider.h"
#include "base/win/scoped_handle.h"
#include "base/scoped_handle.h"
#include "testing/gtest/include/gtest/gtest.h"

#include <initguid.h> // NOLINT - has to be last
Expand Down Expand Up @@ -65,14 +63,14 @@ class TestConsumer: public EtwTraceConsumerBase<TestConsumer> {
::SetEvent(sank_event_.Get());
}

static base::win::ScopedHandle sank_event_;
static ScopedHandle sank_event_;
static EventQueue events_;

private:
DISALLOW_COPY_AND_ASSIGN(TestConsumer);
};

base::win::ScopedHandle TestConsumer::sank_event_;
ScopedHandle TestConsumer::sank_event_;
EventQueue TestConsumer::events_;

const wchar_t* const kTestSessionName = L"TestLogSession";
Expand Down Expand Up @@ -177,8 +175,8 @@ class EtwTraceConsumerRealtimeTest: public testing::Test {
}

TestConsumer consumer_;
base::win::ScopedHandle consumer_ready_;
base::win::ScopedHandle consumer_thread_;
ScopedHandle consumer_ready_;
ScopedHandle consumer_thread_;
};
} // namespace

Expand Down
14 changes: 6 additions & 8 deletions base/win/event_trace_controller_unittest.cc
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2010 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.
//
// Unit tests for event trace controller.

#include <initguid.h> // NOLINT.

#include "base/win/event_trace_controller.h"
#include "base/win/event_trace_provider.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/scoped_handle.h"
#include "base/sys_info.h"
#include "base/win/event_trace_controller.h"
#include "base/win/event_trace_provider.h"
#include "base/win/scoped_handle.h"
#include "testing/gtest/include/gtest/gtest.h"
#include <initguid.h> // NOLINT - must be last.

namespace {

Expand Down Expand Up @@ -52,7 +50,7 @@ class TestingProvider: public EtwTraceProvider {
::SetEvent(callback_event_.Get());
}

base::win::ScopedHandle callback_event_;
ScopedHandle callback_event_;

DISALLOW_COPY_AND_ASSIGN(TestingProvider);
};
Expand Down
6 changes: 3 additions & 3 deletions base/win/win_util.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2010 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.

Expand All @@ -13,11 +13,11 @@

#include "base/logging.h"
#include "base/win/registry.h"
#include "base/scoped_handle.h"
#include "base/scoped_ptr.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/threading/thread_restrictions.h"
#include "base/win/scoped_handle.h"
#include "base/win/windows_version.h"

namespace base {
Expand Down Expand Up @@ -47,7 +47,7 @@ bool GetUserSidString(std::wstring* user_sid) {
HANDLE token = NULL;
if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token))
return false;
base::win::ScopedHandle token_scoped(token);
ScopedHandle token_scoped(token);

DWORD size = sizeof(TOKEN_USER) + SECURITY_MAX_SID_SIZE;
scoped_array<BYTE> user_bytes(new BYTE[size]);
Expand Down
13 changes: 7 additions & 6 deletions ceee/common/process_utils_win.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright (c) 2010 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.
//
Expand All @@ -9,23 +9,24 @@
#include <sddl.h>

#include "base/logging.h"
#include "base/win/scoped_handle.h"
#include "base/scoped_handle.h"
#include "base/win/windows_version.h"
#include "ceee/common/com_utils.h"


namespace process_utils_win {

HRESULT SetThreadIntegrityLevel(HANDLE* thread, const std::wstring& level) {
HANDLE temp_handle = NULL;
BOOL success = ::OpenProcessToken(
::GetCurrentProcess(), MAXIMUM_ALLOWED, &temp_handle);
base::win::ScopedHandle process_token(temp_handle);
ScopedHandle process_token(temp_handle);
temp_handle = NULL;
if (success) {
success = ::DuplicateTokenEx(
process_token, MAXIMUM_ALLOWED, NULL, SecurityImpersonation,
TokenImpersonation, &temp_handle);
base::win::ScopedHandle mic_token(temp_handle);
ScopedHandle mic_token(temp_handle);
temp_handle = NULL;
if (success) {
PSID mic_sid = NULL;
Expand Down Expand Up @@ -97,7 +98,7 @@ HRESULT IsCurrentProcessUacElevated(bool* running_as_admin) {
// All that for an admin-group member, who can run in elevated mode.
// This logic applies to Vista/Win7. The case of earlier systems is handled
// at the start.
base::win::ScopedHandle process_token(temp_handle);
ScopedHandle process_token(temp_handle);
TOKEN_ELEVATION_TYPE elevation_type = TokenElevationTypeDefault;
DWORD variable_len_dummy = 0;
if (!::GetTokenInformation(process_token, TokenElevationType, &elevation_type,
Expand Down Expand Up @@ -330,4 +331,4 @@ void ProcessCompatibilityCheck::ResetState() {
GetInstance()->StandardInitialize();
}

} // namespace process_utils_win
} // namespace com
Loading

0 comments on commit 15d9694

Please sign in to comment.