summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-11 15:40:59 +0000
committerdarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-11 15:40:59 +0000
commit6aa53a1c4b11f4f28b96ded6b49ce0dfc1839cc6 (patch)
tree8ca63881bc11f29aeea8c3c5694fc59d34438d13 /webkit
parent928fb58bd99536f16df3739329cbade0853b3309 (diff)
downloadchromium_src-6aa53a1c4b11f4f28b96ded6b49ce0dfc1839cc6.zip
chromium_src-6aa53a1c4b11f4f28b96ded6b49ce0dfc1839cc6.tar.gz
chromium_src-6aa53a1c4b11f4f28b96ded6b49ce0dfc1839cc6.tar.bz2
Made portable by use of WaitableEvent.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@652 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/tools/test_shell/simple_resource_loader_bridge.cc35
1 files changed, 12 insertions, 23 deletions
diff --git a/webkit/tools/test_shell/simple_resource_loader_bridge.cc b/webkit/tools/test_shell/simple_resource_loader_bridge.cc
index e8dcbf2..f842db7 100644
--- a/webkit/tools/test_shell/simple_resource_loader_bridge.cc
+++ b/webkit/tools/test_shell/simple_resource_loader_bridge.cc
@@ -60,6 +60,7 @@
#include "base/message_loop.h"
#include "base/ref_counted.h"
#include "base/thread.h"
+#include "base/waitable_event.h"
#include "net/base/cookie_monster.h"
#include "net/base/net_util.h"
#include "net/base/upload_data.h"
@@ -330,16 +331,12 @@ class RequestProxy : public URLRequest::Delegate,
class SyncRequestProxy : public RequestProxy {
public:
explicit SyncRequestProxy(ResourceLoaderBridge::SyncLoadResponse* result)
- : event_(::CreateEvent(NULL, TRUE, FALSE, NULL)),
- result_(result) {
+ : event_(true, false), result_(result) {
}
- virtual ~SyncRequestProxy() {
- CloseHandle(event_);
- }
-
- HANDLE event() const {
- return event_;
+ void WaitForCompletion() {
+ if (!event_.Wait())
+ NOTREACHED();
}
// --------------------------------------------------------------------------
@@ -361,12 +358,12 @@ class SyncRequestProxy : public RequestProxy {
virtual void OnCompletedRequest(const URLRequestStatus& status) {
result_->status = status;
- ::SetEvent(event_);
+ event_.Signal();
}
private:
ResourceLoaderBridge::SyncLoadResponse* result_;
- HANDLE event_;
+ base::WaitableEvent event_;
};
//-----------------------------------------------------------------------------
@@ -452,10 +449,7 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
proxy_->Start(NULL, params_.release());
- HANDLE event = static_cast<SyncRequestProxy*>(proxy_)->event();
-
- if (WaitForSingleObject(event, INFINITE) != WAIT_OBJECT_0)
- NOTREACHED();
+ static_cast<SyncRequestProxy*>(proxy_)->WaitForCompletion();
}
private:
@@ -479,27 +473,22 @@ class CookieSetter : public base::RefCountedThreadSafe<CookieSetter> {
class CookieGetter : public base::RefCountedThreadSafe<CookieGetter> {
public:
- CookieGetter()
- : event_(::CreateEvent(NULL, FALSE, FALSE, NULL)) {
- }
-
- ~CookieGetter() {
- CloseHandle(event_);
+ CookieGetter() : event_(false, false) {
}
void Get(const GURL& url) {
result_ = request_context->cookie_store()->GetCookies(url);
- SetEvent(event_);
+ event_.Signal();
}
std::string GetResult() {
- if (WaitForSingleObject(event_, INFINITE) != WAIT_OBJECT_0)
+ if (!event_.Wait())
NOTREACHED();
return result_;
}
private:
- HANDLE event_;
+ base::WaitableEvent event_;
std::string result_;
};