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/asynchronous_policy_loader.h" | 5 #include "chrome/browser/policy/asynchronous_policy_loader.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 | 10 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 void AsynchronousPolicyLoader::InitOnFileThread() { | 87 void AsynchronousPolicyLoader::InitOnFileThread() { |
88 } | 88 } |
89 | 89 |
90 void AsynchronousPolicyLoader::StopOnFileThread() { | 90 void AsynchronousPolicyLoader::StopOnFileThread() { |
91 delegate_.reset(); | 91 delegate_.reset(); |
92 CancelReloadTask(); | 92 CancelReloadTask(); |
93 } | 93 } |
94 | 94 |
95 void AsynchronousPolicyLoader::PostUpdatePolicyTask( | 95 void AsynchronousPolicyLoader::PostUpdatePolicyTask( |
96 DictionaryValue* new_policy) { | 96 DictionaryValue* new_policy) { |
97 // TODO(joaodasilva): make the callback own |new_policy|. | 97 scoped_ptr<DictionaryValue> scoped_policy(new_policy); |
98 origin_loop_->PostTask( | 98 origin_loop_->PostTask( |
99 FROM_HERE, | 99 FROM_HERE, |
100 base::Bind(&AsynchronousPolicyLoader::UpdatePolicy, this, new_policy)); | 100 base::Bind(&AsynchronousPolicyLoader::UpdatePolicy, |
| 101 this, |
| 102 base::Passed(&scoped_policy))); |
101 } | 103 } |
102 | 104 |
103 void AsynchronousPolicyLoader::UpdatePolicy(DictionaryValue* new_policy_raw) { | 105 void AsynchronousPolicyLoader::UpdatePolicy( |
104 scoped_ptr<DictionaryValue> new_policy(new_policy_raw); | 106 scoped_ptr<DictionaryValue> new_policy) { |
105 DCHECK(policy_.get()); | 107 DCHECK(policy_.get()); |
106 policy_.swap(new_policy); | 108 policy_.swap(new_policy); |
107 if (!stopped_) | 109 if (!stopped_) |
108 updates_callback_.Run(); | 110 updates_callback_.Run(); |
109 } | 111 } |
110 | 112 |
111 void AsynchronousPolicyLoader::InitAfterFileThreadAvailable() { | 113 void AsynchronousPolicyLoader::InitAfterFileThreadAvailable() { |
112 if (!stopped_) { | 114 if (!stopped_) { |
113 BrowserThread::PostTask( | 115 BrowserThread::PostTask( |
114 BrowserThread::FILE, FROM_HERE, | 116 BrowserThread::FILE, FROM_HERE, |
115 base::Bind(&AsynchronousPolicyLoader::InitOnFileThread, this)); | 117 base::Bind(&AsynchronousPolicyLoader::InitOnFileThread, this)); |
116 } | 118 } |
117 } | 119 } |
118 | 120 |
119 } // namespace policy | 121 } // namespace policy |
OLD | NEW |