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/test/appcache_test_helper.h" | 5 #include "content/test/appcache_test_helper.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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" |
10 #include "content/browser/appcache/appcache.h" | 11 #include "content/browser/appcache/appcache.h" |
11 #include "content/browser/appcache/appcache_entry.h" | 12 #include "content/browser/appcache/appcache_entry.h" |
12 #include "content/browser/appcache/appcache_group.h" | 13 #include "content/browser/appcache/appcache_group.h" |
13 #include "content/browser/appcache/appcache_service_impl.h" | 14 #include "content/browser/appcache/appcache_service_impl.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 namespace content { | 17 namespace content { |
17 | 18 |
18 AppCacheTestHelper::AppCacheTestHelper() | 19 AppCacheTestHelper::AppCacheTestHelper() |
19 : group_id_(0), | 20 : group_id_(0), |
(...skipping 22 matching lines...) Expand all Loading... |
42 appcache_service->storage(), ++appcache_id_); | 43 appcache_service->storage(), ++appcache_id_); |
43 AppCacheEntry entry(AppCacheEntry::MANIFEST, | 44 AppCacheEntry entry(AppCacheEntry::MANIFEST, |
44 ++response_id_); | 45 ++response_id_); |
45 appcache->AddEntry(manifest_url, entry); | 46 appcache->AddEntry(manifest_url, entry); |
46 appcache->set_complete(true); | 47 appcache->set_complete(true); |
47 appcache_group->AddCache(appcache); | 48 appcache_group->AddCache(appcache); |
48 appcache_service->storage()->StoreGroupAndNewestCache(appcache_group, | 49 appcache_service->storage()->StoreGroupAndNewestCache(appcache_group, |
49 appcache, | 50 appcache, |
50 this); | 51 this); |
51 // OnGroupAndNewestCacheStored will quit the message loop. | 52 // OnGroupAndNewestCacheStored will quit the message loop. |
52 base::MessageLoop::current()->Run(); | 53 base::RunLoop().Run(); |
53 } | 54 } |
54 | 55 |
55 void AppCacheTestHelper::GetOriginsWithCaches(AppCacheServiceImpl* | 56 void AppCacheTestHelper::GetOriginsWithCaches(AppCacheServiceImpl* |
56 appcache_service, std::set<GURL>* origins) { | 57 appcache_service, std::set<GURL>* origins) { |
57 appcache_info_ = new AppCacheInfoCollection; | 58 appcache_info_ = new AppCacheInfoCollection; |
58 origins_ = origins; | 59 origins_ = origins; |
59 appcache_service->GetAllAppCacheInfo( | 60 appcache_service->GetAllAppCacheInfo( |
60 appcache_info_.get(), | 61 appcache_info_.get(), |
61 base::Bind(&AppCacheTestHelper::OnGotAppCacheInfo, | 62 base::Bind(&AppCacheTestHelper::OnGotAppCacheInfo, |
62 base::Unretained(this))); | 63 base::Unretained(this))); |
63 | 64 |
64 // OnGotAppCacheInfo will quit the message loop. | 65 // OnGotAppCacheInfo will quit the message loop. |
65 base::MessageLoop::current()->Run(); | 66 base::RunLoop().Run(); |
66 } | 67 } |
67 | 68 |
68 void AppCacheTestHelper::OnGotAppCacheInfo(int rv) { | 69 void AppCacheTestHelper::OnGotAppCacheInfo(int rv) { |
69 typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin; | 70 typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin; |
70 | 71 |
71 origins_->clear(); | 72 origins_->clear(); |
72 for (InfoByOrigin::const_iterator origin = | 73 for (InfoByOrigin::const_iterator origin = |
73 appcache_info_->infos_by_origin.begin(); | 74 appcache_info_->infos_by_origin.begin(); |
74 origin != appcache_info_->infos_by_origin.end(); ++origin) { | 75 origin != appcache_info_->infos_by_origin.end(); ++origin) { |
75 origins_->insert(origin->first); | 76 origins_->insert(origin->first); |
76 } | 77 } |
77 base::MessageLoop::current()->QuitWhenIdle(); | 78 base::MessageLoop::current()->QuitWhenIdle(); |
78 } | 79 } |
79 | 80 |
80 } // namespace content | 81 } // namespace content |
OLD | NEW |