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

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

Issue 545243002: Clean up BrowsingDataAppCacheHelper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase fixed Created 6 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browsing_data_appcache_helper.h" 5 #include "chrome/browser/browsing_data/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/browsing_data/browsing_data_helper.h" 9 #include "chrome/browser/browsing_data/browsing_data_helper.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/common/url_constants.h"
12 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
13 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
14 #include "content/public/browser/storage_partition.h" 12 #include "content/public/browser/storage_partition.h"
15 13
14 using content::BrowserContext;
16 using content::BrowserThread; 15 using content::BrowserThread;
17 using content::BrowserContext;
18 16
19 BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(Profile* profile) 17 BrowsingDataAppCacheHelper::BrowsingDataAppCacheHelper(
18 BrowserContext* browser_context)
20 : is_fetching_(false), 19 : is_fetching_(false),
21 appcache_service_(BrowserContext::GetDefaultStoragePartition(profile)-> 20 appcache_service_(BrowserContext::GetDefaultStoragePartition(
22 GetAppCacheService()) { 21 browser_context)->GetAppCacheService()) {
23 } 22 }
24 23
25 void BrowsingDataAppCacheHelper::StartFetching(const base::Closure& callback) { 24 void BrowsingDataAppCacheHelper::StartFetching(const base::Closure& callback) {
26 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { 25 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
27 DCHECK(!is_fetching_); 26 DCHECK(!is_fetching_);
28 DCHECK(!callback.is_null()); 27 DCHECK(!callback.is_null());
29 is_fetching_ = true; 28 is_fetching_ = true;
30 info_collection_ = new content::AppCacheInfoCollection; 29 info_collection_ = new content::AppCacheInfoCollection;
31 completion_callback_ = callback; 30 completion_callback_ = callback;
32 BrowserThread::PostTask( 31 BrowserThread::PostTask(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } 79 }
81 80
82 DCHECK_CURRENTLY_ON(BrowserThread::UI); 81 DCHECK_CURRENTLY_ON(BrowserThread::UI);
83 DCHECK(is_fetching_); 82 DCHECK(is_fetching_);
84 is_fetching_ = false; 83 is_fetching_ = false;
85 completion_callback_.Run(); 84 completion_callback_.Run();
86 completion_callback_.Reset(); 85 completion_callback_.Reset();
87 } 86 }
88 87
89 CannedBrowsingDataAppCacheHelper::CannedBrowsingDataAppCacheHelper( 88 CannedBrowsingDataAppCacheHelper::CannedBrowsingDataAppCacheHelper(
90 Profile* profile) 89 BrowserContext* browser_context)
91 : BrowsingDataAppCacheHelper(profile) { 90 : BrowsingDataAppCacheHelper(browser_context) {
92 info_collection_ = new content::AppCacheInfoCollection; 91 info_collection_ = new content::AppCacheInfoCollection;
93 } 92 }
94 93
95 void CannedBrowsingDataAppCacheHelper::AddAppCache(const GURL& manifest_url) { 94 void CannedBrowsingDataAppCacheHelper::AddAppCache(const GURL& manifest_url) {
96 if (!BrowsingDataHelper::HasWebScheme(manifest_url)) 95 if (!BrowsingDataHelper::HasWebScheme(manifest_url))
97 return; // Ignore non-websafe schemes. 96 return; // Ignore non-websafe schemes.
98 97
99 OriginAppCacheInfoMap& origin_map = info_collection_->infos_by_origin; 98 OriginAppCacheInfoMap& origin_map = info_collection_->infos_by_origin;
100 content::AppCacheInfoVector& appcache_infos_ = 99 content::AppCacheInfoVector& appcache_infos_ =
101 origin_map[manifest_url.GetOrigin()]; 100 origin_map[manifest_url.GetOrigin()];
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 completion_callback.Run(); 140 completion_callback.Run();
142 } 141 }
143 142
144 void CannedBrowsingDataAppCacheHelper::DeleteAppCacheGroup( 143 void CannedBrowsingDataAppCacheHelper::DeleteAppCacheGroup(
145 const GURL& manifest_url) { 144 const GURL& manifest_url) {
146 info_collection_->infos_by_origin.erase(manifest_url.GetOrigin()); 145 info_collection_->infos_by_origin.erase(manifest_url.GetOrigin());
147 BrowsingDataAppCacheHelper::DeleteAppCacheGroup(manifest_url); 146 BrowsingDataAppCacheHelper::DeleteAppCacheGroup(manifest_url);
148 } 147 }
149 148
150 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {} 149 CannedBrowsingDataAppCacheHelper::~CannedBrowsingDataAppCacheHelper() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698