| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_LOADER_WIN_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_LOADER_WIN_H_ |
| 6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_LOADER_WIN_H_ | 6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_LOADER_WIN_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/win/object_watcher.h" | 10 #include "base/win/object_watcher.h" |
| 11 #include "chrome/browser/policy/asynchronous_policy_loader.h" | 11 #include "chrome/browser/policy/asynchronous_policy_loader.h" |
| 12 | 12 |
| 13 namespace policy { | 13 namespace policy { |
| 14 | 14 |
| 15 // Keeps watch on Windows Group Policy notification event to trigger a policy | 15 // Keeps watch on Windows Group Policy notification event to trigger a policy |
| 16 // reload when Group Policy changes. | 16 // reload when Group Policy changes. |
| 17 class ConfigurationPolicyLoaderWin | 17 class ConfigurationPolicyLoaderWin |
| 18 : public AsynchronousPolicyLoader, | 18 : public AsynchronousPolicyLoader, |
| 19 public base::win::ObjectWatcher::Delegate, | 19 public base::win::ObjectWatcher::Delegate { |
| 20 public MessageLoop::DestructionObserver { | |
| 21 public: | 20 public: |
| 22 ConfigurationPolicyLoaderWin( | 21 ConfigurationPolicyLoaderWin( |
| 23 AsynchronousPolicyProvider::Delegate* delegate, | 22 AsynchronousPolicyProvider::Delegate* delegate, |
| 24 int reload_interval_minutes); | 23 int reload_interval_minutes); |
| 25 virtual ~ConfigurationPolicyLoaderWin() {} | 24 virtual ~ConfigurationPolicyLoaderWin() {} |
| 26 | 25 |
| 27 protected: | 26 protected: |
| 28 // AsynchronousPolicyLoader overrides: | 27 // AsynchronousPolicyLoader overrides: |
| 29 virtual void InitOnFileThread(); | 28 virtual void InitOnFileThread(); |
| 30 virtual void StopOnFileThread(); | 29 virtual void StopOnFileThread(); |
| 31 | 30 |
| 32 private: | 31 private: |
| 33 // Updates the watchers and schedules the reload task if appropriate. | 32 // Updates the watchers and schedules the reload task if appropriate. |
| 34 void SetupWatches(); | 33 void SetupWatches(); |
| 35 | 34 |
| 36 // Post a reload notification and update the watch machinery. | 35 // Post a reload notification and update the watch machinery. |
| 37 void Reload(); | 36 void Reload(); |
| 38 | 37 |
| 39 // ObjectWatcher::Delegate overrides: | 38 // ObjectWatcher::Delegate overrides: |
| 40 virtual void OnObjectSignaled(HANDLE object); | 39 virtual void OnObjectSignaled(HANDLE object); |
| 41 | 40 |
| 42 // MessageLoop::DestructionObserver overrides: | |
| 43 virtual void WillDestroyCurrentMessageLoop(); | |
| 44 | |
| 45 base::WaitableEvent user_policy_changed_event_; | 41 base::WaitableEvent user_policy_changed_event_; |
| 46 base::WaitableEvent machine_policy_changed_event_; | 42 base::WaitableEvent machine_policy_changed_event_; |
| 47 base::win::ObjectWatcher user_policy_watcher_; | 43 base::win::ObjectWatcher user_policy_watcher_; |
| 48 base::win::ObjectWatcher machine_policy_watcher_; | 44 base::win::ObjectWatcher machine_policy_watcher_; |
| 49 bool user_policy_watcher_failed_; | 45 bool user_policy_watcher_failed_; |
| 50 bool machine_policy_watcher_failed_; | 46 bool machine_policy_watcher_failed_; |
| 51 | 47 |
| 52 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyLoaderWin); | 48 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyLoaderWin); |
| 53 }; | 49 }; |
| 54 | 50 |
| 55 } // namespace policy | 51 } // namespace policy |
| 56 | 52 |
| 57 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_LOADER_WIN_H_ | 53 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_LOADER_WIN_H_ |
| OLD | NEW |