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 "content/browser/appcache/appcache_group.h" | 5 #include "content/browser/appcache/appcache_group.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | |
11 #include "base/logging.h" | 10 #include "base/logging.h" |
12 #include "base/single_thread_task_runner.h" | 11 #include "base/message_loop/message_loop.h" |
13 #include "base/thread_task_runner_handle.h" | |
14 #include "content/browser/appcache/appcache.h" | 12 #include "content/browser/appcache/appcache.h" |
15 #include "content/browser/appcache/appcache_host.h" | 13 #include "content/browser/appcache/appcache_host.h" |
16 #include "content/browser/appcache/appcache_service_impl.h" | 14 #include "content/browser/appcache/appcache_service_impl.h" |
17 #include "content/browser/appcache/appcache_storage.h" | 15 #include "content/browser/appcache/appcache_storage.h" |
18 #include "content/browser/appcache/appcache_update_job.h" | 16 #include "content/browser/appcache/appcache_update_job.h" |
19 | 17 |
20 namespace content { | 18 namespace content { |
21 | 19 |
22 class AppCacheGroup; | 20 class AppCacheGroup; |
23 | 21 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 bool AppCacheGroup::FindObserver( | 223 bool AppCacheGroup::FindObserver( |
226 const UpdateObserver* find_me, | 224 const UpdateObserver* find_me, |
227 const base::ObserverList<UpdateObserver>& observer_list) { | 225 const base::ObserverList<UpdateObserver>& observer_list) { |
228 return observer_list.HasObserver(find_me); | 226 return observer_list.HasObserver(find_me); |
229 } | 227 } |
230 | 228 |
231 void AppCacheGroup::ScheduleUpdateRestart(int delay_ms) { | 229 void AppCacheGroup::ScheduleUpdateRestart(int delay_ms) { |
232 DCHECK(restart_update_task_.IsCancelled()); | 230 DCHECK(restart_update_task_.IsCancelled()); |
233 restart_update_task_.Reset( | 231 restart_update_task_.Reset( |
234 base::Bind(&AppCacheGroup::RunQueuedUpdates, this)); | 232 base::Bind(&AppCacheGroup::RunQueuedUpdates, this)); |
235 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 233 base::MessageLoop::current()->PostDelayedTask( |
236 FROM_HERE, restart_update_task_.callback(), | 234 FROM_HERE, |
| 235 restart_update_task_.callback(), |
237 base::TimeDelta::FromMilliseconds(delay_ms)); | 236 base::TimeDelta::FromMilliseconds(delay_ms)); |
238 } | 237 } |
239 | 238 |
240 void AppCacheGroup::HostDestructionImminent(AppCacheHost* host) { | 239 void AppCacheGroup::HostDestructionImminent(AppCacheHost* host) { |
241 queued_updates_.erase(host); | 240 queued_updates_.erase(host); |
242 if (queued_updates_.empty() && !restart_update_task_.IsCancelled()) | 241 if (queued_updates_.empty() && !restart_update_task_.IsCancelled()) |
243 restart_update_task_.Cancel(); | 242 restart_update_task_.Cancel(); |
244 } | 243 } |
245 | 244 |
246 void AppCacheGroup::SetUpdateAppCacheStatus(UpdateAppCacheStatus status) { | 245 void AppCacheGroup::SetUpdateAppCacheStatus(UpdateAppCacheStatus status) { |
(...skipping 11 matching lines...) Expand all Loading... |
258 // deletion by adding an extra ref in this scope (but only if we're not | 257 // deletion by adding an extra ref in this scope (but only if we're not |
259 // in our destructor). | 258 // in our destructor). |
260 scoped_refptr<AppCacheGroup> protect(is_in_dtor_ ? NULL : this); | 259 scoped_refptr<AppCacheGroup> protect(is_in_dtor_ ? NULL : this); |
261 FOR_EACH_OBSERVER(UpdateObserver, observers_, OnUpdateComplete(this)); | 260 FOR_EACH_OBSERVER(UpdateObserver, observers_, OnUpdateComplete(this)); |
262 if (!queued_updates_.empty()) | 261 if (!queued_updates_.empty()) |
263 ScheduleUpdateRestart(kUpdateRestartDelayMs); | 262 ScheduleUpdateRestart(kUpdateRestartDelayMs); |
264 } | 263 } |
265 } | 264 } |
266 | 265 |
267 } // namespace content | 266 } // namespace content |
OLD | NEW |