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

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

Issue 7384008: Revert 92668 - Remove more unnecessary ChromeURLRequestContext members. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/net/chrome_url_request_context.h" 7 #include "chrome/browser/net/chrome_url_request_context.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
10 #include "content/browser/browser_thread.h" 10 #include "content/browser/browser_thread.h"
11 #include "webkit/appcache/appcache_database.h" 11 #include "webkit/appcache/appcache_database.h"
12 #include "webkit/appcache/appcache_storage.h" 12 #include "webkit/appcache/appcache_storage.h"
13 13
14 using appcache::AppCacheDatabase; 14 using appcache::AppCacheDatabase;
15 15
16 BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(Profile* profile) 16 BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(Profile* profile)
17 : is_fetching_(false), 17 : request_context_getter_(profile->GetRequestContext()),
18 appcache_service_(profile->GetAppCacheService()) { 18 is_fetching_(false) {
19 } 19 }
20 20
21 void BrowsingDataAppCacheHelper::StartFetching(Callback0::Type* callback) { 21 void BrowsingDataAppCacheHelper::StartFetching(Callback0::Type* callback) {
22 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { 22 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
23 DCHECK(!is_fetching_); 23 DCHECK(!is_fetching_);
24 DCHECK(callback); 24 DCHECK(callback);
25 is_fetching_ = true; 25 is_fetching_ = true;
26 info_collection_ = new appcache::AppCacheInfoCollection; 26 info_collection_ = new appcache::AppCacheInfoCollection;
27 completion_callback_.reset(callback); 27 completion_callback_.reset(callback);
28 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableMethod( 28 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableMethod(
29 this, &BrowsingDataAppCacheHelper::StartFetching, callback)); 29 this, &BrowsingDataAppCacheHelper::StartFetching, callback));
30 return; 30 return;
31 } 31 }
32 32
33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
34 appcache_info_callback_ = 34 appcache_info_callback_ =
35 new net::CancelableCompletionCallback<BrowsingDataAppCacheHelper>( 35 new net::CancelableCompletionCallback<BrowsingDataAppCacheHelper>(
36 this, &BrowsingDataAppCacheHelper::OnFetchComplete); 36 this, &BrowsingDataAppCacheHelper::OnFetchComplete);
37 appcache_service_->GetAllAppCacheInfo(info_collection_, 37 GetAppCacheService()->GetAllAppCacheInfo(info_collection_,
38 appcache_info_callback_); 38 appcache_info_callback_);
39 } 39 }
40 40
41 void BrowsingDataAppCacheHelper::CancelNotification() { 41 void BrowsingDataAppCacheHelper::CancelNotification() {
42 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { 42 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
43 completion_callback_.reset(); 43 completion_callback_.reset();
44 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableMethod( 44 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableMethod(
45 this, &BrowsingDataAppCacheHelper::CancelNotification)); 45 this, &BrowsingDataAppCacheHelper::CancelNotification));
46 return; 46 return;
47 } 47 }
48 48
49 if (appcache_info_callback_) 49 if (appcache_info_callback_)
50 appcache_info_callback_.release()->Cancel(); 50 appcache_info_callback_.release()->Cancel();
51 } 51 }
52 52
53 void BrowsingDataAppCacheHelper::DeleteAppCacheGroup( 53 void BrowsingDataAppCacheHelper::DeleteAppCacheGroup(
54 const GURL& manifest_url) { 54 const GURL& manifest_url) {
55 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { 55 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
56 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableMethod( 56 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableMethod(
57 this, &BrowsingDataAppCacheHelper::DeleteAppCacheGroup, 57 this, &BrowsingDataAppCacheHelper::DeleteAppCacheGroup,
58 manifest_url)); 58 manifest_url));
59 return; 59 return;
60 } 60 }
61 appcache_service_->DeleteAppCacheGroup(manifest_url, NULL); 61 GetAppCacheService()->DeleteAppCacheGroup(manifest_url, NULL);
62 } 62 }
63 63
64 BrowsingDataAppCacheHelper::~BrowsingDataAppCacheHelper() {} 64 BrowsingDataAppCacheHelper::~BrowsingDataAppCacheHelper() {}
65 65
66 void BrowsingDataAppCacheHelper::OnFetchComplete(int rv) { 66 void BrowsingDataAppCacheHelper::OnFetchComplete(int rv) {
67 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { 67 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) {
68 // Filter out appache info entries for extensions. Extension state is not 68 // Filter out appache info entries for extensions. Extension state is not
69 // considered browsing data. 69 // considered browsing data.
70 typedef std::map<GURL, appcache::AppCacheInfoVector> InfoByOrigin; 70 typedef std::map<GURL, appcache::AppCacheInfoVector> InfoByOrigin;
71 InfoByOrigin& origin_map = info_collection_->infos_by_origin; 71 InfoByOrigin& origin_map = info_collection_->infos_by_origin;
(...skipping 13 matching lines...) Expand all
85 85
86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
87 DCHECK(is_fetching_); 87 DCHECK(is_fetching_);
88 is_fetching_ = false; 88 is_fetching_ = false;
89 if (completion_callback_ != NULL) { 89 if (completion_callback_ != NULL) {
90 completion_callback_->Run(); 90 completion_callback_->Run();
91 completion_callback_.reset(); 91 completion_callback_.reset();
92 } 92 }
93 } 93 }
94 94
95 ChromeAppCacheService* BrowsingDataAppCacheHelper::GetAppCacheService() {
96 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
97 ChromeURLRequestContext* request_context =
98 reinterpret_cast<ChromeURLRequestContext*>(
99 request_context_getter_->GetURLRequestContext());
100 return request_context ? request_context->appcache_service()
101 : NULL;
102 }
103
95 CannedBrowsingDataAppCacheHelper::CannedBrowsingDataAppCacheHelper( 104 CannedBrowsingDataAppCacheHelper::CannedBrowsingDataAppCacheHelper(
96 Profile* profile) 105 Profile* profile)
97 : BrowsingDataAppCacheHelper(profile), 106 : BrowsingDataAppCacheHelper(profile),
98 profile_(profile) { 107 profile_(profile) {
99 info_collection_ = new appcache::AppCacheInfoCollection; 108 info_collection_ = new appcache::AppCacheInfoCollection;
100 } 109 }
101 110
102 CannedBrowsingDataAppCacheHelper* CannedBrowsingDataAppCacheHelper::Clone() { 111 CannedBrowsingDataAppCacheHelper* CannedBrowsingDataAppCacheHelper::Clone() {
103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
104 CannedBrowsingDataAppCacheHelper* clone = 113 CannedBrowsingDataAppCacheHelper* clone =
(...skipping 29 matching lines...) Expand all
134 return info_collection_->infos_by_origin.empty(); 143 return info_collection_->infos_by_origin.empty();
135 } 144 }
136 145
137 void CannedBrowsingDataAppCacheHelper::StartFetching( 146 void CannedBrowsingDataAppCacheHelper::StartFetching(
138 Callback0::Type* completion_callback) { 147 Callback0::Type* completion_callback) {
139 completion_callback->Run(); 148 completion_callback->Run();
140 delete completion_callback; 149 delete completion_callback;
141 } 150 }
142 151
143 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {} 152 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {}
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data_appcache_helper.h ('k') | chrome/browser/download/download_file_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698