| OLD | NEW |
| 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 "chrome/browser/policy/async_policy_provider.h" | 5 #include "chrome/browser/policy/async_policy_provider.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| 11 #include "chrome/browser/policy/async_policy_loader.h" | 11 #include "chrome/browser/policy/async_policy_loader.h" |
| 12 #include "chrome/browser/policy/policy_bundle.h" | 12 #include "chrome/browser/policy/policy_bundle.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 | 14 |
| 15 using content::BrowserThread; | 15 using content::BrowserThread; |
| 16 | 16 |
| 17 namespace policy { | 17 namespace policy { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 // Helper for a PostTaskAndReply used as a synchronization point between the | 21 // Helper for a PostTaskAndReply used as a synchronization point between the |
| 22 // main thread and FILE thread. See AsyncPolicyProvider::RefreshPolicies. | 22 // main thread and FILE thread. See AsyncPolicyProvider::RefreshPolicies. |
| 23 void Nop() {} | 23 void Nop() {} |
| 24 | 24 |
| 25 } // namespace | 25 } // namespace |
| 26 | 26 |
| 27 AsyncPolicyProvider::AsyncPolicyProvider( | 27 AsyncPolicyProvider::AsyncPolicyProvider(scoped_ptr<AsyncPolicyLoader> loader) |
| 28 const PolicyDefinitionList* policy_list, | 28 : loader_(loader.release()), |
| 29 scoped_ptr<AsyncPolicyLoader> loader) | |
| 30 : ConfigurationPolicyProvider(policy_list), | |
| 31 loader_(loader.release()), | |
| 32 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 29 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 33 // The FILE thread isn't ready early during startup. Post a task to the | 30 // The FILE thread isn't ready early during startup. Post a task to the |
| 34 // current loop to resume initialization on FILE once the loops are spinning. | 31 // current loop to resume initialization on FILE once the loops are spinning. |
| 35 MessageLoop::current()->PostTask( | 32 MessageLoop::current()->PostTask( |
| 36 FROM_HERE, | 33 FROM_HERE, |
| 37 base::Bind(&AsyncPolicyProvider::InitWithLoopsReady, | 34 base::Bind(&AsyncPolicyProvider::InitWithLoopsReady, |
| 38 weak_factory_.GetWeakPtr())); | 35 weak_factory_.GetWeakPtr())); |
| 39 // Make an immediate synchronous load on startup. | 36 // Make an immediate synchronous load on startup. |
| 40 OnLoaderReloaded(loader_->InitialLoad()); | 37 OnLoaderReloaded(loader_->InitialLoad()); |
| 41 } | 38 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 base::WeakPtr<AsyncPolicyProvider> weak_this, | 114 base::WeakPtr<AsyncPolicyProvider> weak_this, |
| 118 scoped_ptr<PolicyBundle> bundle) { | 115 scoped_ptr<PolicyBundle> bundle) { |
| 119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 120 loop->PostTask(FROM_HERE, | 117 loop->PostTask(FROM_HERE, |
| 121 base::Bind(&AsyncPolicyProvider::OnLoaderReloaded, | 118 base::Bind(&AsyncPolicyProvider::OnLoaderReloaded, |
| 122 weak_this, | 119 weak_this, |
| 123 base::Passed(&bundle))); | 120 base::Passed(&bundle))); |
| 124 } | 121 } |
| 125 | 122 |
| 126 } // namespace policy | 123 } // namespace policy |
| OLD | NEW |