Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: content/test/appcache_test_helper.cc

Issue 344493002: Move all remaining appcache-related code to content namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/browser/appcache/appcache.h"
11 #include "content/browser/appcache/appcache_entry.h"
12 #include "content/browser/appcache/appcache_group.h"
13 #include "content/browser/appcache/appcache_service_impl.h"
10 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
11 #include "webkit/browser/appcache/appcache.h"
12 #include "webkit/browser/appcache/appcache_entry.h"
13 #include "webkit/browser/appcache/appcache_group.h"
14 #include "webkit/browser/appcache/appcache_service_impl.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 AppCacheTestHelper::AppCacheTestHelper() 18 AppCacheTestHelper::AppCacheTestHelper()
19 : group_id_(0), 19 : group_id_(0),
20 appcache_id_(0), 20 appcache_id_(0),
21 response_id_(0), 21 response_id_(0),
22 origins_(NULL) {} 22 origins_(NULL) {}
23 23
24 AppCacheTestHelper::~AppCacheTestHelper() {} 24 AppCacheTestHelper::~AppCacheTestHelper() {}
25 25
26 void AppCacheTestHelper::OnGroupAndNewestCacheStored( 26 void AppCacheTestHelper::OnGroupAndNewestCacheStored(
27 appcache::AppCacheGroup* /*group*/, 27 AppCacheGroup* /*group*/,
28 appcache::AppCache* /*newest_cache*/, 28 AppCache* /*newest_cache*/,
29 bool success, 29 bool success,
30 bool /*would_exceed_quota*/) { 30 bool /*would_exceed_quota*/) {
31 ASSERT_TRUE(success); 31 ASSERT_TRUE(success);
32 base::MessageLoop::current()->Quit(); 32 base::MessageLoop::current()->Quit();
33 } 33 }
34 34
35 void AppCacheTestHelper::AddGroupAndCache(appcache::AppCacheServiceImpl* 35 void AppCacheTestHelper::AddGroupAndCache(AppCacheServiceImpl*
36 appcache_service, const GURL& manifest_url) { 36 appcache_service, const GURL& manifest_url) {
37 appcache::AppCacheGroup* appcache_group = 37 AppCacheGroup* appcache_group =
38 new appcache::AppCacheGroup(appcache_service->storage(), 38 new AppCacheGroup(appcache_service->storage(),
39 manifest_url, 39 manifest_url,
40 ++group_id_); 40 ++group_id_);
41 appcache::AppCache* appcache = new appcache::AppCache( 41 AppCache* appcache = new AppCache(
42 appcache_service->storage(), ++appcache_id_); 42 appcache_service->storage(), ++appcache_id_);
43 appcache::AppCacheEntry entry(appcache::AppCacheEntry::MANIFEST, 43 AppCacheEntry entry(AppCacheEntry::MANIFEST,
44 ++response_id_); 44 ++response_id_);
45 appcache->AddEntry(manifest_url, entry); 45 appcache->AddEntry(manifest_url, entry);
46 appcache->set_complete(true); 46 appcache->set_complete(true);
47 appcache_group->AddCache(appcache); 47 appcache_group->AddCache(appcache);
48 appcache_service->storage()->StoreGroupAndNewestCache(appcache_group, 48 appcache_service->storage()->StoreGroupAndNewestCache(appcache_group,
49 appcache, 49 appcache,
50 this); 50 this);
51 // OnGroupAndNewestCacheStored will quit the message loop. 51 // OnGroupAndNewestCacheStored will quit the message loop.
52 base::MessageLoop::current()->Run(); 52 base::MessageLoop::current()->Run();
53 } 53 }
54 54
55 void AppCacheTestHelper::GetOriginsWithCaches(appcache::AppCacheServiceImpl* 55 void AppCacheTestHelper::GetOriginsWithCaches(AppCacheServiceImpl*
56 appcache_service, std::set<GURL>* origins) { 56 appcache_service, std::set<GURL>* origins) {
57 appcache_info_ = new appcache::AppCacheInfoCollection; 57 appcache_info_ = new AppCacheInfoCollection;
58 origins_ = origins; 58 origins_ = origins;
59 appcache_service->GetAllAppCacheInfo( 59 appcache_service->GetAllAppCacheInfo(
60 appcache_info_.get(), 60 appcache_info_.get(),
61 base::Bind(&AppCacheTestHelper::OnGotAppCacheInfo, 61 base::Bind(&AppCacheTestHelper::OnGotAppCacheInfo,
62 base::Unretained(this))); 62 base::Unretained(this)));
63 63
64 // OnGotAppCacheInfo will quit the message loop. 64 // OnGotAppCacheInfo will quit the message loop.
65 base::MessageLoop::current()->Run(); 65 base::MessageLoop::current()->Run();
66 } 66 }
67 67
68 void AppCacheTestHelper::OnGotAppCacheInfo(int rv) { 68 void AppCacheTestHelper::OnGotAppCacheInfo(int rv) {
69 typedef std::map<GURL, appcache::AppCacheInfoVector> InfoByOrigin; 69 typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin;
70 70
71 origins_->clear(); 71 origins_->clear();
72 for (InfoByOrigin::const_iterator origin = 72 for (InfoByOrigin::const_iterator origin =
73 appcache_info_->infos_by_origin.begin(); 73 appcache_info_->infos_by_origin.begin();
74 origin != appcache_info_->infos_by_origin.end(); ++origin) { 74 origin != appcache_info_->infos_by_origin.end(); ++origin) {
75 origins_->insert(origin->first); 75 origins_->insert(origin->first);
76 } 76 }
77 base::MessageLoop::current()->Quit(); 77 base::MessageLoop::current()->Quit();
78 } 78 }
79 79
80 } // namespace content 80 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698