summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-16 20:43:49 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-16 20:43:49 +0000
commite69b4232604cd9452c530c08e8bd159770b51521 (patch)
treede5895a78663a7a0d9c4faf3e36c573dbc3593d0 /base
parentb12c83d58dbe64119f0e1471bf93dca9f823267b (diff)
downloadchromium_src-e69b4232604cd9452c530c08e8bd159770b51521.zip
chromium_src-e69b4232604cd9452c530c08e8bd159770b51521.tar.gz
chromium_src-e69b4232604cd9452c530c08e8bd159770b51521.tar.bz2
Remove unused shared_event.
Review URL: http://codereview.chromium.org/7439 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3484 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/SConscript2
-rw-r--r--base/build/base.vcproj8
-rw-r--r--base/build/base_unittests.vcproj4
-rw-r--r--base/shared_event.cc80
-rw-r--r--base/shared_event.h63
-rw-r--r--base/shared_event_unittest.cc57
6 files changed, 0 insertions, 214 deletions
diff --git a/base/SConscript b/base/SConscript
index 252fab2f..34e8d43 100644
--- a/base/SConscript
+++ b/base/SConscript
@@ -88,7 +88,6 @@ if env['PLATFORM'] == 'win32':
# This group all depends on MessageLoop.
'idle_timer.cc',
'object_watcher.cc',
- 'shared_event.cc', # Is this used?
'watchdog.cc',
'resource_util.cc', # Uses HMODULE, but may be abstractable.
@@ -308,7 +307,6 @@ if env['PLATFORM'] == 'win32':
'clipboard_unittest.cc',
'idletimer_unittest.cc',
'process_util_unittest.cc',
- 'shared_event_unittest.cc',
'stats_table_unittest.cc',
'watchdog_unittest.cc',
'gfx/native_theme_unittest.cc',
diff --git a/base/build/base.vcproj b/base/build/base.vcproj
index 69de369..5db1e7a 100644
--- a/base/build/base.vcproj
+++ b/base/build/base.vcproj
@@ -638,14 +638,6 @@
>
</File>
<File
- RelativePath="..\shared_event.cc"
- >
- </File>
- <File
- RelativePath="..\shared_event.h"
- >
- </File>
- <File
RelativePath="..\shared_memory.h"
>
</File>
diff --git a/base/build/base_unittests.vcproj b/base/build/base_unittests.vcproj
index 50b14cc..0f37520 100644
--- a/base/build/base_unittests.vcproj
+++ b/base/build/base_unittests.vcproj
@@ -276,10 +276,6 @@
>
</File>
<File
- RelativePath="..\shared_event_unittest.cc"
- >
- </File>
- <File
RelativePath="..\shared_memory_unittest.cc"
>
</File>
diff --git a/base/shared_event.cc b/base/shared_event.cc
deleted file mode 100644
index 3a9ce9c..0000000
--- a/base/shared_event.cc
+++ /dev/null
@@ -1,80 +0,0 @@
-// 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.
-
-#include "base/shared_event.h"
-#include "base/logging.h"
-#include "base/time.h"
-
-SharedEvent::~SharedEvent() {
- Close();
-}
-
-bool SharedEvent::Create(bool manual_reset, bool initial_state) {
- DCHECK(!event_handle_);
- event_handle_ = CreateEvent(NULL /* security attributes */, manual_reset,
- initial_state, NULL /* name */);
- DCHECK(event_handle_);
- return !!event_handle_;
-}
-
-void SharedEvent::Close() {
- if (event_handle_) {
- BOOL rv = CloseHandle(event_handle_);
- DCHECK(rv);
- event_handle_ = NULL;
- }
-}
-
-bool SharedEvent::SetSignaledState(bool signaled) {
- DCHECK(event_handle_);
- BOOL rv;
- if (signaled) {
- rv = SetEvent(event_handle_);
- } else {
- rv = ResetEvent(event_handle_);
- }
- return rv ? true : false;
-}
-
-bool SharedEvent::IsSignaled() {
- DCHECK(event_handle_);
- DWORD event_state = ::WaitForSingleObject(event_handle_, 0);
- DCHECK(WAIT_OBJECT_0 == event_state || WAIT_TIMEOUT == event_state);
- return event_state == WAIT_OBJECT_0;
-}
-
-bool SharedEvent::WaitUntilSignaled(const TimeDelta& timeout) {
- DCHECK(event_handle_);
- DWORD event_state = ::WaitForSingleObject(event_handle_,
- static_cast<DWORD>(timeout.InMillisecondsF()));
- return event_state == WAIT_OBJECT_0;
-}
-
-bool SharedEvent::WaitForeverUntilSignaled() {
- DCHECK(event_handle_);
- DWORD event_state = ::WaitForSingleObject(event_handle_,
- INFINITE);
- return event_state == WAIT_OBJECT_0;
-}
-
-bool SharedEvent::ShareToProcess(ProcessHandle process,
- SharedEventHandle *new_handle) {
- DCHECK(event_handle_);
- HANDLE event_handle_copy;
- BOOL rv = DuplicateHandle(GetCurrentProcess(), event_handle_, process,
- &event_handle_copy, 0, FALSE, DUPLICATE_SAME_ACCESS);
-
- if (rv)
- *new_handle = event_handle_copy;
- return rv ? true : false;
-}
-
-bool SharedEvent::GiveToProcess(ProcessHandle process,
- SharedEventHandle *new_handle) {
- bool rv = ShareToProcess(process, new_handle);
- if (rv)
- Close();
- return rv;
-}
-
diff --git a/base/shared_event.h b/base/shared_event.h
deleted file mode 100644
index ee9e12d..0000000
--- a/base/shared_event.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// 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.
-
-#ifndef BASE_SHARED_EVENT__
-#define BASE_SHARED_EVENT__
-
-#include "base/process_util.h"
-
-class TimeDelta;
-
-typedef HANDLE SharedEventHandle;
-
-class SharedEvent {
- public:
- // Create a new SharedEvent.
- SharedEvent() : event_handle_(NULL) { }
-
- // Create a SharedEvent from an existing SharedEventHandle. The new
- // SharedEvent now owns the SharedEventHandle and will close it.
- SharedEvent(SharedEventHandle event_handle) : event_handle_(event_handle) { }
- ~SharedEvent();
-
- // Create the SharedEvent.
- bool Create(bool manual_reset, bool initial_state);
-
- // Close the SharedEvent.
- void Close();
-
- // If |signaled| is true, set the signaled state, otherwise, set to nonsignaled.
- // Returns false if we can't set the signaled state.
- bool SetSignaledState(bool signaled);
-
- // Returns true if the SharedEvent is signaled.
- bool IsSignaled();
-
- // Blocks until the event is signaled with a maximum wait time of |timeout|.
- // Returns true if the object is signaled within the timeout.
- bool WaitUntilSignaled(const TimeDelta& timeout);
-
- // Blocks until the event is signaled. Returns true if the object is
- // signaled, otherwise an error occurred.
- bool WaitForeverUntilSignaled();
-
- // Get access to the underlying OS handle for this event.
- SharedEventHandle handle() { return event_handle_; }
-
- // Share this SharedEvent with |process|. |new_handle| is an output
- // parameter to receive the handle for use in |process|. Returns false if we
- // are unable to share the SharedEvent.
- bool ShareToProcess(ProcessHandle process, SharedEventHandle *new_handle);
-
- // The same as ShareToProcess followed by closing the event.
- bool GiveToProcess(ProcessHandle process, SharedEventHandle *new_handle);
-
- private:
- SharedEventHandle event_handle_;
-
- DISALLOW_EVIL_CONSTRUCTORS(SharedEvent);
-};
-
-#endif // BASE_SHARED_EVENT__
-
diff --git a/base/shared_event_unittest.cc b/base/shared_event_unittest.cc
deleted file mode 100644
index dfad4e8..0000000
--- a/base/shared_event_unittest.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-// 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.
-
-#include <process.h> // _beginthreadex
-
-#include "base/lock.h"
-#include "base/scoped_ptr.h"
-#include "base/shared_event.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-class SharedEventTest : public testing::Test {
-};
-
-Lock lock;
-
-unsigned __stdcall MultipleThreadMain(void* param) {
- SharedEvent* shared_event = reinterpret_cast<SharedEvent*>(param);
- AutoLock l(lock);
- shared_event->SetSignaledState(!shared_event->IsSignaled());
- return 0;
-}
-
-}
-
-TEST(SharedEventTest, ThreadSignaling) {
- // Create a set of 5 threads to each open a shared event and flip the
- // signaled state. Verify that when the threads complete, the final state is
- // not-signaled.
- // I admit this doesn't test much, but short of spawning separate processes
- // and using IPC with a SharedEventHandle, there's not much to unittest.
- const int kNumThreads = 5;
- HANDLE threads[kNumThreads];
-
- scoped_ptr<SharedEvent> shared_event(new SharedEvent);
- shared_event->Create(true, true);
-
- // Spawn the threads.
- for (int16 index = 0; index < kNumThreads; index++) {
- void *argument = reinterpret_cast<void*>(shared_event.get());
- unsigned thread_id;
- threads[index] = reinterpret_cast<HANDLE>(
- _beginthreadex(NULL, 0, MultipleThreadMain, argument, 0, &thread_id));
- EXPECT_NE(threads[index], static_cast<HANDLE>(NULL));
- }
-
- // Wait for the threads to finish.
- for (int index = 0; index < kNumThreads; index++) {
- DWORD rv = WaitForSingleObject(threads[index], 60*1000);
- EXPECT_EQ(rv, WAIT_OBJECT_0); // verify all threads finished
- CloseHandle(threads[index]);
- }
- EXPECT_FALSE(shared_event->IsSignaled());
-}
-