diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-15 22:25:11 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-15 22:25:11 +0000 |
commit | 1c4947ffee0b7f5672737b542eb6adf466fcb223 (patch) | |
tree | ca2b1631479523a3a397fac842fe0870f422193f /chrome/plugin/webplugin_proxy.cc | |
parent | c0ce93d64e2374f29acf2130c5324dc54762f0fa (diff) | |
download | chromium_src-1c4947ffee0b7f5672737b542eb6adf466fcb223.zip chromium_src-1c4947ffee0b7f5672737b542eb6adf466fcb223.tar.gz chromium_src-1c4947ffee0b7f5672737b542eb6adf466fcb223.tar.bz2 |
WaitableEvent is the replacement for Windows events. Previously in the code, a HANDLE from CreateEvent was used for signaling, both within a process and across processes.
WaitableEvent is the cross platform replacement for this. To convert:
* HANDLE -> base::WaitableEvent*
* ScopedHandle -> scoped_ptr<base::WaitableEvent>
* CreateEvent -> new base::WaitableEvent
* SetEvent -> base::WaitableEvent::Signal
* ResetEvent -> base::WaitableEvent::Reset
* ObjectWatcher -> base::WaitableEventWatcher
* WaitForMultipleObjects -> static base::WaitableEvent::WaitMany
ObjectWatcher remains for Windows specific code. WaitableEventWatcher has an identical interface save,
* It uses WaitableEvents, not HANDLEs
* It returns void from StartWatching and StopWatcher, rather than errors. System internal errors are fatal to the address space
IMPORTANT: There are semantic differences between the different platforms. WaitableEvents on Windows are implemented on top of events. Windows events work across process and this is used mostly for modal dialog support. Windows events can be duplicated with DuplicateHandle.
On other platforms, WaitableEvent works only within a single process. In the future we shall have to replace the current uses of cross-process events with IPCs.
BEWARE: HANDLE, on Windows, is a void *. Since any pointer type coerces to void *, you can pass a WaitableEvent * where a HANDLE is expected without any build-time errors.
Review URL: http://codereview.chromium.org/16554
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8126 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin/webplugin_proxy.cc')
-rw-r--r-- | chrome/plugin/webplugin_proxy.cc | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc index 0bd6ed8..bb7ee5c 100644 --- a/chrome/plugin/webplugin_proxy.cc +++ b/chrome/plugin/webplugin_proxy.cc @@ -8,6 +8,7 @@ #include "base/scoped_handle.h" #include "base/shared_memory.h" #include "base/singleton.h" +#include "base/waitable_event.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/plugin_messages.h" #include "chrome/common/win_util.h" @@ -47,7 +48,7 @@ WebPluginProxy::WebPluginProxy( FALSE, 0); DCHECK(result) << "Couldn't duplicate the modal dialog handle for the plugin."; - modal_dialog_event_.Set(event); + modal_dialog_event_.reset(new base::WaitableEvent(event)); } WebPluginProxy::~WebPluginProxy() { @@ -121,7 +122,7 @@ NPObject* WebPluginProxy::GetWindowScriptNPObject() { window_npobject_ = NPObjectProxy::Create(channel_, npobject_route_id, npobject_ptr, - modal_dialog_event_.Get()); + modal_dialog_event_.get()); return window_npobject_; } @@ -141,7 +142,7 @@ NPObject* WebPluginProxy::GetPluginElement() { plugin_element_ = NPObjectProxy::Create(channel_, npobject_route_id, npobject_ptr, - modal_dialog_event_.Get()); + modal_dialog_event_.get()); return plugin_element_; } @@ -170,8 +171,9 @@ void WebPluginProxy::ShowModalHTMLDialog(const GURL& url, int width, int height, // Create a new event and set it. This forces us to pump messages while // waiting for a response (which won't come until the dialog is closed). This // avoids a deadlock. - ScopedHandle event(CreateEvent(NULL, FALSE, TRUE, NULL)); - msg->set_pump_messages_event(event); + scoped_ptr<base::WaitableEvent> event( + new base::WaitableEvent(false, true)); + msg->set_pump_messages_event(event.get()); Send(msg); } |