Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(552)

Side by Side Diff: content/browser/plugin_service_impl.cc

Issue 12094106: Refactor: Simplify WaitableEventWatcher. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/plugin_service_impl.h" 5 #include "content/browser/plugin_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 void PluginServiceImpl::StartWatchingPlugins() { 162 void PluginServiceImpl::StartWatchingPlugins() {
163 // Start watching for changes in the plugin list. This means watching 163 // Start watching for changes in the plugin list. This means watching
164 // for changes in the Windows registry keys and on both Windows and POSIX 164 // for changes in the Windows registry keys and on both Windows and POSIX
165 // watch for changes in the paths that are expected to contain plugins. 165 // watch for changes in the paths that are expected to contain plugins.
166 #if defined(OS_WIN) 166 #if defined(OS_WIN)
167 if (hkcu_key_.Create(HKEY_CURRENT_USER, 167 if (hkcu_key_.Create(HKEY_CURRENT_USER,
168 webkit::npapi::kRegistryMozillaPlugins, 168 webkit::npapi::kRegistryMozillaPlugins,
169 KEY_NOTIFY) == ERROR_SUCCESS) { 169 KEY_NOTIFY) == ERROR_SUCCESS) {
170 if (hkcu_key_.StartWatching() == ERROR_SUCCESS) { 170 if (hkcu_key_.StartWatching() == ERROR_SUCCESS) {
171 hkcu_event_.reset(new base::WaitableEvent(hkcu_key_.watch_event())); 171 hkcu_event_.reset(new base::WaitableEvent(hkcu_key_.watch_event()));
172 hkcu_watcher_.StartWatching(hkcu_event_.get(), this); 172 base::WaitableEventWatcher::EventCallback callback =
173 base::Bind(&PluginServiceImpl::OnWaitableEventSignaled,
174 base::Unretained(this));
175 hkcu_watcher_.StartWatching(hkcu_event_.get(), callback);
173 } 176 }
174 } 177 }
175 if (hklm_key_.Create(HKEY_LOCAL_MACHINE, 178 if (hklm_key_.Create(HKEY_LOCAL_MACHINE,
176 webkit::npapi::kRegistryMozillaPlugins, 179 webkit::npapi::kRegistryMozillaPlugins,
177 KEY_NOTIFY) == ERROR_SUCCESS) { 180 KEY_NOTIFY) == ERROR_SUCCESS) {
178 if (hklm_key_.StartWatching() == ERROR_SUCCESS) { 181 if (hklm_key_.StartWatching() == ERROR_SUCCESS) {
179 hklm_event_.reset(new base::WaitableEvent(hklm_key_.watch_event())); 182 hklm_event_.reset(new base::WaitableEvent(hklm_key_.watch_event()));
180 hklm_watcher_.StartWatching(hklm_event_.get(), this); 183 base::WaitableEventWatcher::EventCallback callback =
184 base::Bind(&PluginServiceImpl::OnWaitableEventSignaled,
185 base::Unretained(this));
186 hklm_watcher_.StartWatching(hklm_event_.get(), callback);
181 } 187 }
182 } 188 }
183 #endif 189 #endif
184 #if defined(OS_POSIX) && !defined(OS_OPENBSD) && !defined(OS_ANDROID) 190 #if defined(OS_POSIX) && !defined(OS_OPENBSD) && !defined(OS_ANDROID)
185 // On ChromeOS the user can't install plugins anyway and on Windows all 191 // On ChromeOS the user can't install plugins anyway and on Windows all
186 // important plugins register themselves in the registry so no need to do that. 192 // important plugins register themselves in the registry so no need to do that.
187 193
188 // Get the list of all paths for registering the FilePathWatchers 194 // Get the list of all paths for registering the FilePathWatchers
189 // that will track and if needed reload the list of plugins on runtime. 195 // that will track and if needed reload the list of plugins on runtime.
190 std::vector<FilePath> plugin_dirs; 196 std::vector<FilePath> plugin_dirs;
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 void PluginServiceImpl::GetInternalPlugins( 709 void PluginServiceImpl::GetInternalPlugins(
704 std::vector<webkit::WebPluginInfo>* plugins) { 710 std::vector<webkit::WebPluginInfo>* plugins) {
705 plugin_list_->GetInternalPlugins(plugins); 711 plugin_list_->GetInternalPlugins(plugins);
706 } 712 }
707 713
708 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { 714 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() {
709 return plugin_list_; 715 return plugin_list_;
710 } 716 }
711 717
712 } // namespace content 718 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698