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

Side by Side Diff: chrome/browser/browsing_data_appcache_helper.cc

Issue 9425026: Remove getters for HTML5 related objects from the ResourceContext interface. Half of them weren't u… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix race condition Created 8 years, 10 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/browsing_data_appcache_helper.h" 5 #include "chrome/browser/browsing_data_appcache_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 "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/resource_context.h"
12 #include "webkit/appcache/appcache_database.h" 13 #include "webkit/appcache/appcache_database.h"
13 #include "webkit/appcache/appcache_storage.h" 14 #include "webkit/appcache/appcache_storage.h"
14 15
15 using appcache::AppCacheDatabase; 16 using appcache::AppCacheDatabase;
16 using content::BrowserContext; 17 using content::BrowserContext;
17 using content::BrowserThread; 18 using content::BrowserThread;
19 using content::ResourceContext;
18 20
19 BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(Profile* profile) 21 BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(Profile* profile)
20 : is_fetching_(false), 22 : is_fetching_(false),
21 appcache_service_(BrowserContext::GetAppCacheService(profile)) { 23 resource_context_(profile->GetResourceContext()) {
22 } 24 }
23 25
24 void BrowsingDataAppCacheHelper::StartFetching(const base::Closure& callback) { 26 void BrowsingDataAppCacheHelper::StartFetching(const base::Closure& callback) {
25 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { 27 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
26 DCHECK(!is_fetching_); 28 DCHECK(!is_fetching_);
27 DCHECK_EQ(false, callback.is_null()); 29 DCHECK_EQ(false, callback.is_null());
28 is_fetching_ = true; 30 is_fetching_ = true;
29 info_collection_ = new appcache::AppCacheInfoCollection; 31 info_collection_ = new appcache::AppCacheInfoCollection;
30 completion_callback_ = callback; 32 completion_callback_ = callback;
31 BrowserThread::PostTask( 33 BrowserThread::PostTask(
32 BrowserThread::IO, FROM_HERE, 34 BrowserThread::IO, FROM_HERE,
33 base::Bind(&BrowsingDataAppCacheHelper::StartFetching, this, callback)); 35 base::Bind(&BrowsingDataAppCacheHelper::StartFetching, this, callback));
34 return; 36 return;
35 } 37 }
36 38
37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
38 appcache_info_callback_.Reset( 40 appcache_info_callback_.Reset(
39 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete, 41 base::Bind(&BrowsingDataAppCacheHelper::OnFetchComplete,
40 base::Unretained(this))); 42 base::Unretained(this)));
41 appcache_service_->GetAllAppCacheInfo(info_collection_, 43 ResourceContext::GetAppCacheService(resource_context_)->
42 appcache_info_callback_.callback()); 44 GetAllAppCacheInfo(info_collection_, appcache_info_callback_.callback());
43 } 45 }
44 46
45 void BrowsingDataAppCacheHelper::CancelNotification() { 47 void BrowsingDataAppCacheHelper::CancelNotification() {
46 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { 48 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
47 completion_callback_.Reset(); 49 completion_callback_.Reset();
48 BrowserThread::PostTask( 50 BrowserThread::PostTask(
49 BrowserThread::IO, FROM_HERE, 51 BrowserThread::IO, FROM_HERE,
50 base::Bind(&BrowsingDataAppCacheHelper::CancelNotification, this)); 52 base::Bind(&BrowsingDataAppCacheHelper::CancelNotification, this));
51 return; 53 return;
52 } 54 }
53 55
54 appcache_info_callback_.Cancel(); 56 appcache_info_callback_.Cancel();
55 } 57 }
56 58
57 void BrowsingDataAppCacheHelper::DeleteAppCacheGroup( 59 void BrowsingDataAppCacheHelper::DeleteAppCacheGroup(
58 const GURL& manifest_url) { 60 const GURL& manifest_url) {
59 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { 61 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
60 BrowserThread::PostTask( 62 BrowserThread::PostTask(
61 BrowserThread::IO, FROM_HERE, 63 BrowserThread::IO, FROM_HERE,
62 base::Bind(&BrowsingDataAppCacheHelper::DeleteAppCacheGroup, this, 64 base::Bind(&BrowsingDataAppCacheHelper::DeleteAppCacheGroup, this,
63 manifest_url)); 65 manifest_url));
64 return; 66 return;
65 } 67 }
66 68
67 appcache_service_->DeleteAppCacheGroup( 69 ResourceContext::GetAppCacheService(resource_context_)->DeleteAppCacheGroup(
68 manifest_url, net::CompletionCallback()); 70 manifest_url, net::CompletionCallback());
69 } 71 }
70 72
71 BrowsingDataAppCacheHelper::~BrowsingDataAppCacheHelper() {} 73 BrowsingDataAppCacheHelper::~BrowsingDataAppCacheHelper() {}
72 74
73 void BrowsingDataAppCacheHelper::OnFetchComplete(int rv) { 75 void BrowsingDataAppCacheHelper::OnFetchComplete(int rv) {
74 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { 76 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) {
75 // Filter out appcache info entries for extensions. Extension state is not 77 // Filter out appcache info entries for extensions. Extension state is not
76 // considered browsing data. 78 // considered browsing data.
77 typedef std::map<GURL, appcache::AppCacheInfoVector> InfoByOrigin; 79 typedef std::map<GURL, appcache::AppCacheInfoVector> InfoByOrigin;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 bool CannedBrowsingDataAppCacheHelper::empty() const { 142 bool CannedBrowsingDataAppCacheHelper::empty() const {
141 return info_collection_->infos_by_origin.empty(); 143 return info_collection_->infos_by_origin.empty();
142 } 144 }
143 145
144 void CannedBrowsingDataAppCacheHelper::StartFetching( 146 void CannedBrowsingDataAppCacheHelper::StartFetching(
145 const base::Closure& completion_callback) { 147 const base::Closure& completion_callback) {
146 completion_callback.Run(); 148 completion_callback.Run();
147 } 149 }
148 150
149 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {} 151 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698