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