OLD | NEW |
1 // Copyright (c) 2011 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 #include "chrome/browser/policy/configuration_policy_loader_win.h" | 5 #include "chrome/browser/policy/configuration_policy_loader_win.h" |
6 | 6 |
7 #include <userenv.h> | 7 #include <userenv.h> |
8 | 8 |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 if (!RegisterGPNotification(user_policy_changed_event_.handle(), false)) { | 26 if (!RegisterGPNotification(user_policy_changed_event_.handle(), false)) { |
27 PLOG(WARNING) << "Failed to register user group policy notification"; | 27 PLOG(WARNING) << "Failed to register user group policy notification"; |
28 user_policy_watcher_failed_ = true; | 28 user_policy_watcher_failed_ = true; |
29 } | 29 } |
30 if (!RegisterGPNotification(machine_policy_changed_event_.handle(), true)) { | 30 if (!RegisterGPNotification(machine_policy_changed_event_.handle(), true)) { |
31 PLOG(WARNING) << "Failed to register machine group policy notification."; | 31 PLOG(WARNING) << "Failed to register machine group policy notification."; |
32 machine_policy_watcher_failed_ = true; | 32 machine_policy_watcher_failed_ = true; |
33 } | 33 } |
34 } | 34 } |
35 | 35 |
| 36 void ConfigurationPolicyLoaderWin::Reload(bool force) { |
| 37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 38 // Reset the watches BEFORE reading the individual policies to avoid |
| 39 // missing a change notification. |
| 40 SetupWatches(); |
| 41 AsynchronousPolicyLoader::Reload(force); |
| 42 } |
| 43 |
36 void ConfigurationPolicyLoaderWin::InitOnFileThread() { | 44 void ConfigurationPolicyLoaderWin::InitOnFileThread() { |
37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
38 AsynchronousPolicyLoader::InitOnFileThread(); | 46 AsynchronousPolicyLoader::InitOnFileThread(); |
39 SetupWatches(); | 47 SetupWatches(); |
40 } | 48 } |
41 | 49 |
42 void ConfigurationPolicyLoaderWin::StopOnFileThread() { | 50 void ConfigurationPolicyLoaderWin::StopOnFileThread() { |
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
44 user_policy_watcher_.StopWatching(); | 52 user_policy_watcher_.StopWatching(); |
45 machine_policy_watcher_.StopWatching(); | 53 machine_policy_watcher_.StopWatching(); |
(...skipping 16 matching lines...) Expand all Loading... |
62 !machine_policy_watcher_.StartWatching( | 70 !machine_policy_watcher_.StartWatching( |
63 machine_policy_changed_event_.handle(), this)) { | 71 machine_policy_changed_event_.handle(), this)) { |
64 LOG(WARNING) << "Failed to start watch for machine policy change event"; | 72 LOG(WARNING) << "Failed to start watch for machine policy change event"; |
65 machine_policy_watcher_failed_ = true; | 73 machine_policy_watcher_failed_ = true; |
66 } | 74 } |
67 | 75 |
68 if (user_policy_watcher_failed_ || machine_policy_watcher_failed_) | 76 if (user_policy_watcher_failed_ || machine_policy_watcher_failed_) |
69 ScheduleFallbackReloadTask(); | 77 ScheduleFallbackReloadTask(); |
70 } | 78 } |
71 | 79 |
72 void ConfigurationPolicyLoaderWin::Reload() { | |
73 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
74 // Reset the watches BEFORE reading the individual policies to avoid | |
75 // missing a change notification. | |
76 SetupWatches(); | |
77 AsynchronousPolicyLoader::Reload(); | |
78 } | |
79 | |
80 void ConfigurationPolicyLoaderWin::OnObjectSignaled(HANDLE object) { | 80 void ConfigurationPolicyLoaderWin::OnObjectSignaled(HANDLE object) { |
81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
82 DCHECK(object == user_policy_changed_event_.handle() || | 82 DCHECK(object == user_policy_changed_event_.handle() || |
83 object == machine_policy_changed_event_.handle()) | 83 object == machine_policy_changed_event_.handle()) |
84 << "unexpected object signaled policy reload, obj = " | 84 << "unexpected object signaled policy reload, obj = " |
85 << std::showbase << std::hex << object; | 85 << std::showbase << std::hex << object; |
86 Reload(); | 86 Reload(false); |
87 } | 87 } |
88 | 88 |
89 } // namespace policy | 89 } // namespace policy |
OLD | NEW |