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 30 matching lines...) Expand all Loading... |
41 stopped_ = true; | 41 stopped_ = true; |
42 BrowserThread::PostTask( | 42 BrowserThread::PostTask( |
43 BrowserThread::FILE, FROM_HERE, | 43 BrowserThread::FILE, FROM_HERE, |
44 base::Bind(&AsynchronousPolicyLoader::StopOnFileThread, this)); | 44 base::Bind(&AsynchronousPolicyLoader::StopOnFileThread, this)); |
45 } | 45 } |
46 } | 46 } |
47 | 47 |
48 AsynchronousPolicyLoader::~AsynchronousPolicyLoader() { | 48 AsynchronousPolicyLoader::~AsynchronousPolicyLoader() { |
49 } | 49 } |
50 | 50 |
51 void AsynchronousPolicyLoader::Reload() { | 51 void AsynchronousPolicyLoader::Reload(bool force) { |
52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
53 if (delegate_.get()) { | 53 if (delegate_.get()) { |
54 PostUpdatePolicyTask(delegate_->Load()); | 54 PostUpdatePolicyTask(delegate_->Load()); |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 void AsynchronousPolicyLoader::CancelReloadTask() { | 58 void AsynchronousPolicyLoader::CancelReloadTask() { |
59 weak_ptr_factory_.InvalidateWeakPtrs(); | 59 weak_ptr_factory_.InvalidateWeakPtrs(); |
60 } | 60 } |
61 | 61 |
(...skipping 12 matching lines...) Expand all Loading... |
74 | 74 |
75 void AsynchronousPolicyLoader::ScheduleFallbackReloadTask() { | 75 void AsynchronousPolicyLoader::ScheduleFallbackReloadTask() { |
76 // As a safeguard in case that the load delegate failed to timely notice a | 76 // As a safeguard in case that the load delegate failed to timely notice a |
77 // change in policy, schedule a reload task that'll make us recheck after a | 77 // change in policy, schedule a reload task that'll make us recheck after a |
78 // reasonable interval. | 78 // reasonable interval. |
79 ScheduleReloadTask(reload_interval_); | 79 ScheduleReloadTask(reload_interval_); |
80 } | 80 } |
81 | 81 |
82 void AsynchronousPolicyLoader::ReloadFromTask() { | 82 void AsynchronousPolicyLoader::ReloadFromTask() { |
83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
84 Reload(); | 84 Reload(false); |
85 } | 85 } |
86 | 86 |
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 |
(...skipping 15 matching lines...) Expand all Loading... |
110 | 110 |
111 void AsynchronousPolicyLoader::InitAfterFileThreadAvailable() { | 111 void AsynchronousPolicyLoader::InitAfterFileThreadAvailable() { |
112 if (!stopped_) { | 112 if (!stopped_) { |
113 BrowserThread::PostTask( | 113 BrowserThread::PostTask( |
114 BrowserThread::FILE, FROM_HERE, | 114 BrowserThread::FILE, FROM_HERE, |
115 base::Bind(&AsynchronousPolicyLoader::InitOnFileThread, this)); | 115 base::Bind(&AsynchronousPolicyLoader::InitOnFileThread, this)); |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 } // namespace policy | 119 } // namespace policy |
OLD | NEW |