1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_LOADER_WIN_H_ 6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_LOADER_WIN_H_ 7 #pragma once 8 9 #include "base/synchronization/waitable_event.h" 10 #include "base/win/object_watcher.h" 11 #include "chrome/browser/policy/asynchronous_policy_loader.h" 12 13 namespace policy { 14 15 // Keeps watch on Windows Group Policy notification event to trigger a policy 16 // reload when Group Policy changes. 17 class ConfigurationPolicyLoaderWin 18 : public AsynchronousPolicyLoader, 19 public base::win::ObjectWatcher::Delegate { 20 public: 21 ConfigurationPolicyLoaderWin( 22 AsynchronousPolicyProvider::Delegate* delegate, 23 int reload_interval_minutes); ~ConfigurationPolicyLoaderWin()24 virtual ~ConfigurationPolicyLoaderWin() {} 25 26 protected: 27 // AsynchronousPolicyLoader overrides: 28 virtual void InitOnFileThread(); 29 virtual void StopOnFileThread(); 30 31 private: 32 // Updates the watchers and schedules the reload task if appropriate. 33 void SetupWatches(); 34 35 // Post a reload notification and update the watch machinery. 36 void Reload(); 37 38 // ObjectWatcher::Delegate overrides: 39 virtual void OnObjectSignaled(HANDLE object); 40 41 base::WaitableEvent user_policy_changed_event_; 42 base::WaitableEvent machine_policy_changed_event_; 43 base::win::ObjectWatcher user_policy_watcher_; 44 base::win::ObjectWatcher machine_policy_watcher_; 45 bool user_policy_watcher_failed_; 46 bool machine_policy_watcher_failed_; 47 48 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyLoaderWin); 49 }; 50 51 } // namespace policy 52 53 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_LOADER_WIN_H_ 54