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

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

Issue 11953112: Refactor: Simplify WaitableEventWatcher. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed on windows Created 7 years, 11 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 if (registry_watcher_callback_.is_null())
173 registry_watcher_callback_ =
174 base::Bind(&PluginServiceImpl::OnWaitableEventSignaled,
175 base::Unretained(this));
176 hkcu_watcher_.StartWatching(hkcu_event_.get(),
177 &registry_watcher_callback_);
173 } 178 }
174 } 179 }
175 if (hklm_key_.Create(HKEY_LOCAL_MACHINE, 180 if (hklm_key_.Create(HKEY_LOCAL_MACHINE,
176 webkit::npapi::kRegistryMozillaPlugins, 181 webkit::npapi::kRegistryMozillaPlugins,
177 KEY_NOTIFY) == ERROR_SUCCESS) { 182 KEY_NOTIFY) == ERROR_SUCCESS) {
178 if (hklm_key_.StartWatching() == ERROR_SUCCESS) { 183 if (hklm_key_.StartWatching() == ERROR_SUCCESS) {
179 hklm_event_.reset(new base::WaitableEvent(hklm_key_.watch_event())); 184 hklm_event_.reset(new base::WaitableEvent(hklm_key_.watch_event()));
180 hklm_watcher_.StartWatching(hklm_event_.get(), this); 185 if (registry_watcher_callback_.is_null())
186 registry_watcher_callback_ =
187 base::Bind(&PluginServiceImpl::OnWaitableEventSignaled,
188 base::Unretained(this));
189 hklm_watcher_.StartWatching(hklm_event_.get(),
190 &registry_watcher_callback_);
181 } 191 }
182 } 192 }
183 #endif 193 #endif
184 #if defined(OS_POSIX) && !defined(OS_OPENBSD) && !defined(OS_ANDROID) 194 #if defined(OS_POSIX) && !defined(OS_OPENBSD) && !defined(OS_ANDROID)
185 // On ChromeOS the user can't install plugins anyway and on Windows all 195 // 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. 196 // important plugins register themselves in the registry so no need to do that.
187 197
188 // Get the list of all paths for registering the FilePathWatchers 198 // Get the list of all paths for registering the FilePathWatchers
189 // that will track and if needed reload the list of plugins on runtime. 199 // that will track and if needed reload the list of plugins on runtime.
190 std::vector<FilePath> plugin_dirs; 200 std::vector<FilePath> plugin_dirs;
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 void PluginServiceImpl::GetInternalPlugins( 713 void PluginServiceImpl::GetInternalPlugins(
704 std::vector<webkit::WebPluginInfo>* plugins) { 714 std::vector<webkit::WebPluginInfo>* plugins) {
705 plugin_list_->GetInternalPlugins(plugins); 715 plugin_list_->GetInternalPlugins(plugins);
706 } 716 }
707 717
708 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { 718 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() {
709 return plugin_list_; 719 return plugin_list_;
710 } 720 }
711 721
712 } // namespace content 722 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698