| 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 #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 "chrome/browser/browser_thread.h" | 9 #include "chrome/browser/browser_thread.h" |
| 10 | 10 |
| 11 namespace policy { | 11 namespace policy { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 24 } | 24 } |
| 25 if (!RegisterGPNotification(machine_policy_changed_event_.handle(), true)) { | 25 if (!RegisterGPNotification(machine_policy_changed_event_.handle(), true)) { |
| 26 PLOG(WARNING) << "Failed to register machine group policy notification."; | 26 PLOG(WARNING) << "Failed to register machine group policy notification."; |
| 27 machine_policy_watcher_failed_ = true; | 27 machine_policy_watcher_failed_ = true; |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 | 30 |
| 31 void ConfigurationPolicyLoaderWin::InitOnFileThread() { | 31 void ConfigurationPolicyLoaderWin::InitOnFileThread() { |
| 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 33 AsynchronousPolicyLoader::InitOnFileThread(); | 33 AsynchronousPolicyLoader::InitOnFileThread(); |
| 34 MessageLoop::current()->AddDestructionObserver(this); | |
| 35 SetupWatches(); | 34 SetupWatches(); |
| 36 } | 35 } |
| 37 | 36 |
| 38 void ConfigurationPolicyLoaderWin::StopOnFileThread() { | 37 void ConfigurationPolicyLoaderWin::StopOnFileThread() { |
| 39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 40 MessageLoop::current()->RemoveDestructionObserver(this); | |
| 41 user_policy_watcher_.StopWatching(); | 39 user_policy_watcher_.StopWatching(); |
| 42 machine_policy_watcher_.StopWatching(); | 40 machine_policy_watcher_.StopWatching(); |
| 43 AsynchronousPolicyLoader::StopOnFileThread(); | 41 AsynchronousPolicyLoader::StopOnFileThread(); |
| 44 } | 42 } |
| 45 | 43 |
| 46 void ConfigurationPolicyLoaderWin::SetupWatches() { | 44 void ConfigurationPolicyLoaderWin::SetupWatches() { |
| 47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 48 CancelReloadTask(); | 46 CancelReloadTask(); |
| 49 | 47 |
| 50 if (!user_policy_watcher_failed_ && | 48 if (!user_policy_watcher_failed_ && |
| (...skipping 23 matching lines...) Expand all Loading... |
| 74 | 72 |
| 75 void ConfigurationPolicyLoaderWin::OnObjectSignaled(HANDLE object) { | 73 void ConfigurationPolicyLoaderWin::OnObjectSignaled(HANDLE object) { |
| 76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 77 DCHECK(object == user_policy_changed_event_.handle() || | 75 DCHECK(object == user_policy_changed_event_.handle() || |
| 78 object == machine_policy_changed_event_.handle()) | 76 object == machine_policy_changed_event_.handle()) |
| 79 << "unexpected object signaled policy reload, obj = " | 77 << "unexpected object signaled policy reload, obj = " |
| 80 << std::showbase << std::hex << object; | 78 << std::showbase << std::hex << object; |
| 81 Reload(); | 79 Reload(); |
| 82 } | 80 } |
| 83 | 81 |
| 84 void ConfigurationPolicyLoaderWin:: | |
| 85 WillDestroyCurrentMessageLoop() { | |
| 86 CancelReloadTask(); | |
| 87 MessageLoop::current()->RemoveDestructionObserver(this); | |
| 88 } | |
| 89 | |
| 90 } // namespace policy | 82 } // namespace policy |
| OLD | NEW |