Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/policy/core/common/async_policy_provider.h" | 5 #include "components/policy/core/common/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/location.h" | 9 #include "base/location.h" |
| 10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 base::ThreadTaskRunnerHandle::Get(), | 41 base::ThreadTaskRunnerHandle::Get(), |
| 42 weak_factory_.GetWeakPtr()); | 42 weak_factory_.GetWeakPtr()); |
| 43 bool post = loader_->task_runner()->PostTask( | 43 bool post = loader_->task_runner()->PostTask( |
| 44 FROM_HERE, | 44 FROM_HERE, |
| 45 base::Bind(&AsyncPolicyLoader::Init, | 45 base::Bind(&AsyncPolicyLoader::Init, |
| 46 base::Unretained(loader_.get()), | 46 base::Unretained(loader_.get()), |
| 47 callback)); | 47 callback)); |
| 48 DCHECK(post) << "AsyncPolicyProvider::Init() called with threads not running"; | 48 DCHECK(post) << "AsyncPolicyProvider::Init() called with threads not running"; |
| 49 } | 49 } |
| 50 | 50 |
| 51 PolicySource AsyncPolicyProvider::source() const { | |
|
Thiemo Nagel
2015/09/01 17:40:36
Remove.
fhorschig
2015/09/04 06:53:54
Done.
| |
| 52 return loader_->source(); | |
| 53 } | |
| 54 | |
| 51 void AsyncPolicyProvider::Shutdown() { | 55 void AsyncPolicyProvider::Shutdown() { |
| 52 DCHECK(CalledOnValidThread()); | 56 DCHECK(CalledOnValidThread()); |
| 53 // Note on the lifetime of |loader_|: | 57 // Note on the lifetime of |loader_|: |
| 54 // The |loader_| lives on the background thread, and is deleted from here. | 58 // The |loader_| lives on the background thread, and is deleted from here. |
| 55 // This means that posting tasks on the |loader_| to the background thread | 59 // This means that posting tasks on the |loader_| to the background thread |
| 56 // from the AsyncPolicyProvider is always safe, since a potential DeleteSoon() | 60 // from the AsyncPolicyProvider is always safe, since a potential DeleteSoon() |
| 57 // is only posted from here. The |loader_| posts back to the | 61 // is only posted from here. The |loader_| posts back to the |
| 58 // AsyncPolicyProvider through the |update_callback_|, which has a WeakPtr to | 62 // AsyncPolicyProvider through the |update_callback_|, which has a WeakPtr to |
| 59 // |this|. | 63 // |this|. |
| 60 // If threads are spinning, delete the loader on the thread it lives on. If | 64 // If threads are spinning, delete the loader on the thread it lives on. If |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 scoped_refptr<base::SingleThreadTaskRunner> runner, | 127 scoped_refptr<base::SingleThreadTaskRunner> runner, |
| 124 base::WeakPtr<AsyncPolicyProvider> weak_this, | 128 base::WeakPtr<AsyncPolicyProvider> weak_this, |
| 125 scoped_ptr<PolicyBundle> bundle) { | 129 scoped_ptr<PolicyBundle> bundle) { |
| 126 runner->PostTask(FROM_HERE, | 130 runner->PostTask(FROM_HERE, |
| 127 base::Bind(&AsyncPolicyProvider::OnLoaderReloaded, | 131 base::Bind(&AsyncPolicyProvider::OnLoaderReloaded, |
| 128 weak_this, | 132 weak_this, |
| 129 base::Passed(&bundle))); | 133 base::Passed(&bundle))); |
| 130 } | 134 } |
| 131 | 135 |
| 132 } // namespace policy | 136 } // namespace policy |
| OLD | NEW |