OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/mock_appcache_storage.h" | 5 #include "content/browser/appcache/mock_appcache_storage.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | |
9 #include "base/logging.h" | 8 #include "base/logging.h" |
10 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
11 #include "base/single_thread_task_runner.h" | 10 #include "base/message_loop/message_loop.h" |
12 #include "base/stl_util.h" | 11 #include "base/stl_util.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_entry.h" | 13 #include "content/browser/appcache/appcache_entry.h" |
16 #include "content/browser/appcache/appcache_group.h" | 14 #include "content/browser/appcache/appcache_group.h" |
17 #include "content/browser/appcache/appcache_response.h" | 15 #include "content/browser/appcache/appcache_response.h" |
18 #include "content/browser/appcache/appcache_service_impl.h" | 16 #include "content/browser/appcache/appcache_service_impl.h" |
19 | 17 |
20 // This is a quick and easy 'mock' implementation of the storage interface | 18 // This is a quick and easy 'mock' implementation of the storage interface |
21 // that doesn't put anything to disk. | 19 // that doesn't put anything to disk. |
22 // | 20 // |
23 // We simply add an extra reference to objects when they're put in storage, | 21 // We simply add an extra reference to objects when they're put in storage, |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 // 'manifest_url' in the working set any longer. | 451 // 'manifest_url' in the working set any longer. |
454 working_set()->RemoveGroup(group.get()); | 452 working_set()->RemoveGroup(group.get()); |
455 | 453 |
456 if (delegate_ref->delegate) | 454 if (delegate_ref->delegate) |
457 delegate_ref->delegate->OnGroupMadeObsolete( | 455 delegate_ref->delegate->OnGroupMadeObsolete( |
458 group.get(), true, response_code); | 456 group.get(), true, response_code); |
459 } | 457 } |
460 | 458 |
461 void MockAppCacheStorage::ScheduleTask(const base::Closure& task) { | 459 void MockAppCacheStorage::ScheduleTask(const base::Closure& task) { |
462 pending_tasks_.push_back(task); | 460 pending_tasks_.push_back(task); |
463 base::ThreadTaskRunnerHandle::Get()->PostTask( | 461 base::MessageLoop::current()->PostTask( |
464 FROM_HERE, base::Bind(&MockAppCacheStorage::RunOnePendingTask, | 462 FROM_HERE, |
465 weak_factory_.GetWeakPtr())); | 463 base::Bind(&MockAppCacheStorage::RunOnePendingTask, |
| 464 weak_factory_.GetWeakPtr())); |
466 } | 465 } |
467 | 466 |
468 void MockAppCacheStorage::RunOnePendingTask() { | 467 void MockAppCacheStorage::RunOnePendingTask() { |
469 DCHECK(!pending_tasks_.empty()); | 468 DCHECK(!pending_tasks_.empty()); |
470 base::Closure task = pending_tasks_.front(); | 469 base::Closure task = pending_tasks_.front(); |
471 pending_tasks_.pop_front(); | 470 pending_tasks_.pop_front(); |
472 task.Run(); | 471 task.Run(); |
473 } | 472 } |
474 | 473 |
475 void MockAppCacheStorage::AddStoredCache(AppCache* cache) { | 474 void MockAppCacheStorage::AddStoredCache(AppCache* cache) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 bool MockAppCacheStorage::ShouldCacheLoadAppearAsync(const AppCache* cache) { | 542 bool MockAppCacheStorage::ShouldCacheLoadAppearAsync(const AppCache* cache) { |
544 if (!cache) | 543 if (!cache) |
545 return true; | 544 return true; |
546 | 545 |
547 // If the 'stored' ref is the only ref, real storage will have to load from | 546 // If the 'stored' ref is the only ref, real storage will have to load from |
548 // the database. | 547 // the database. |
549 return IsCacheStored(cache) && cache->HasOneRef(); | 548 return IsCacheStored(cache) && cache->HasOneRef(); |
550 } | 549 } |
551 | 550 |
552 } // namespace content | 551 } // namespace content |
OLD | NEW |