diff options
author | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-31 22:37:55 +0000 |
---|---|---|
committer | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-31 22:37:55 +0000 |
commit | 06a07d94f8b33645f18b3bc3d67be6d8aeb158fa (patch) | |
tree | 4352c7d41eda55a73785d4ac9fac1e5d44f49e33 /content | |
parent | c462b22f1f644cc17568c4bd6f095bb89e5586a7 (diff) | |
download | chromium_src-06a07d94f8b33645f18b3bc3d67be6d8aeb158fa.zip chromium_src-06a07d94f8b33645f18b3bc3d67be6d8aeb158fa.tar.gz chromium_src-06a07d94f8b33645f18b3bc3d67be6d8aeb158fa.tar.bz2 |
Refactor: Simplify WaitableEventWatcher.
This change uses a callback instead of a delegate for specifying what
should be called when a WaitableEvent occurs.
This simplifies the class and gets rid of a workaround internal to the
class to prevent name collision on "Delegate" inner classes.
Tested (on linux and windows):
ninja -C out/Debug chrome
out/Debug/base_unittests --gtest_filter=*WaitableEventWatcherTest*
BUG=
Review URL: https://chromiumcodereview.appspot.com/11953112
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179987 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/plugin_data_remover_impl_browsertest.cc | 10 | ||||
-rw-r--r-- | content/browser/plugin_service_impl.cc | 10 | ||||
-rw-r--r-- | content/browser/plugin_service_impl.h | 7 |
3 files changed, 16 insertions, 11 deletions
diff --git a/content/browser/plugin_data_remover_impl_browsertest.cc b/content/browser/plugin_data_remover_impl_browsertest.cc index 101987d..98b06d7 100644 --- a/content/browser/plugin_data_remover_impl_browsertest.cc +++ b/content/browser/plugin_data_remover_impl_browsertest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/base_paths.h" +#include "base/callback.h" #include "base/command_line.h" #include "base/path_service.h" #include "base/synchronization/waitable_event_watcher.h" @@ -19,12 +20,11 @@ namespace { const char* kNPAPITestPluginMimeType = "application/vnd.npapi-test"; } -class PluginDataRemoverTest : public ContentBrowserTest, - public base::WaitableEventWatcher::Delegate { +class PluginDataRemoverTest : public ContentBrowserTest { public: PluginDataRemoverTest() {} - virtual void OnWaitableEventSignaled(base::WaitableEvent* waitable_event) { + void OnWaitableEventSignaled(base::WaitableEvent* waitable_event) { MessageLoop::current()->Quit(); } @@ -51,7 +51,9 @@ IN_PROC_BROWSER_TEST_F(PluginDataRemoverTest, RemoveData) { base::WaitableEventWatcher watcher; base::WaitableEvent* event = plugin_data_remover.StartRemoving(base::Time()); - watcher.StartWatching(event, this); + watcher.StartWatching( + event, + base::Bind(&PluginDataRemoverTest::OnWaitableEventSignaled, this)); RunMessageLoop(); } diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc index 9b90fe0..e083774 100644 --- a/content/browser/plugin_service_impl.cc +++ b/content/browser/plugin_service_impl.cc @@ -186,7 +186,10 @@ void PluginServiceImpl::StartWatchingPlugins() { KEY_NOTIFY) == ERROR_SUCCESS) { if (hkcu_key_.StartWatching() == ERROR_SUCCESS) { hkcu_event_.reset(new base::WaitableEvent(hkcu_key_.watch_event())); - hkcu_watcher_.StartWatching(hkcu_event_.get(), this); + base::WaitableEventWatcher::EventCallback callback = + base::Bind(&PluginServiceImpl::OnWaitableEventSignaled, + base::Unretained(this)); + hkcu_watcher_.StartWatching(hkcu_event_.get(), callback); } } if (hklm_key_.Create(HKEY_LOCAL_MACHINE, @@ -194,7 +197,10 @@ void PluginServiceImpl::StartWatchingPlugins() { KEY_NOTIFY) == ERROR_SUCCESS) { if (hklm_key_.StartWatching() == ERROR_SUCCESS) { hklm_event_.reset(new base::WaitableEvent(hklm_key_.watch_event())); - hklm_watcher_.StartWatching(hklm_event_.get(), this); + base::WaitableEventWatcher::EventCallback callback = + base::Bind(&PluginServiceImpl::OnWaitableEventSignaled, + base::Unretained(this)); + hklm_watcher_.StartWatching(hklm_event_.get(), callback); } } #endif diff --git a/content/browser/plugin_service_impl.h b/content/browser/plugin_service_impl.h index 8808c4b..81ef427 100644 --- a/content/browser/plugin_service_impl.h +++ b/content/browser/plugin_service_impl.h @@ -64,8 +64,7 @@ struct PluginServiceFilterParams { }; class CONTENT_EXPORT PluginServiceImpl - : NON_EXPORTED_BASE(public PluginService), - public base::WaitableEventWatcher::Delegate { + : NON_EXPORTED_BASE(public PluginService) { public: // Returns the PluginServiceImpl singleton. static PluginServiceImpl* GetInstance(); @@ -157,9 +156,7 @@ class CONTENT_EXPORT PluginServiceImpl PluginServiceImpl(); virtual ~PluginServiceImpl(); - // base::WaitableEventWatcher::Delegate implementation. - virtual void OnWaitableEventSignaled( - base::WaitableEvent* waitable_event) OVERRIDE; + void OnWaitableEventSignaled(base::WaitableEvent* waitable_event); // Returns the plugin process host corresponding to the plugin process that // has been started by this service. Returns NULL if no process has been |