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

Side by Side Diff: webkit/appcache/appcache_storage_impl.cc

Issue 7720022: Third-party appcache blocking. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Keeping up to date with trunk. Created 9 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 | 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 "webkit/appcache/appcache_storage_impl.h" 5 #include "webkit/appcache/appcache_storage_impl.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "net/base/cache_type.h" 14 #include "net/base/cache_type.h"
15 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
16 #include "sql/connection.h" 16 #include "sql/connection.h"
17 #include "sql/transaction.h" 17 #include "sql/transaction.h"
18 #include "webkit/appcache/appcache.h" 18 #include "webkit/appcache/appcache.h"
19 #include "webkit/appcache/appcache_database.h" 19 #include "webkit/appcache/appcache_database.h"
20 #include "webkit/appcache/appcache_entry.h" 20 #include "webkit/appcache/appcache_entry.h"
21 #include "webkit/appcache/appcache_group.h" 21 #include "webkit/appcache/appcache_group.h"
22 #include "webkit/appcache/appcache_histograms.h" 22 #include "webkit/appcache/appcache_histograms.h"
23 #include "webkit/appcache/appcache_policy.h"
24 #include "webkit/appcache/appcache_quota_client.h" 23 #include "webkit/appcache/appcache_quota_client.h"
25 #include "webkit/appcache/appcache_response.h" 24 #include "webkit/appcache/appcache_response.h"
26 #include "webkit/appcache/appcache_service.h" 25 #include "webkit/appcache/appcache_service.h"
27 #include "webkit/appcache/appcache_thread.h" 26 #include "webkit/appcache/appcache_thread.h"
28 #include "webkit/quota/quota_client.h" 27 #include "webkit/quota/quota_client.h"
29 #include "webkit/quota/quota_manager.h" 28 #include "webkit/quota/quota_manager.h"
30 #include "webkit/quota/special_storage_policy.h" 29 #include "webkit/quota/special_storage_policy.h"
31 30
32 namespace appcache { 31 namespace appcache {
33 32
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 fallback_url_ = (*iter)->fallback_entry_url; 942 fallback_url_ = (*iter)->fallback_entry_url;
944 fallback_entry_ = AppCacheEntry( 943 fallback_entry_ = AppCacheEntry(
945 entry_record.flags, entry_record.response_id); 944 entry_record.flags, entry_record.response_id);
946 return true; // We found one. 945 return true; // We found one.
947 } 946 }
948 } 947 }
949 return false; // We didn't find a match. 948 return false; // We didn't find a match.
950 } 949 }
951 950
952 void AppCacheStorageImpl::FindMainResponseTask::RunCompleted() { 951 void AppCacheStorageImpl::FindMainResponseTask::RunCompleted() {
953 storage_->CheckPolicyAndCallOnMainResponseFound( 952 storage_->CallOnMainResponseFound(
954 &delegates_, url_, entry_, fallback_url_, fallback_entry_, 953 &delegates_, url_, entry_, fallback_url_, fallback_entry_,
955 cache_id_, manifest_url_); 954 cache_id_, manifest_url_);
956 } 955 }
957 956
958 // MarkEntryAsForeignTask ------- 957 // MarkEntryAsForeignTask -------
959 958
960 class AppCacheStorageImpl::MarkEntryAsForeignTask : public DatabaseTask { 959 class AppCacheStorageImpl::MarkEntryAsForeignTask : public DatabaseTask {
961 public: 960 public:
962 MarkEntryAsForeignTask( 961 MarkEntryAsForeignTask(
963 AppCacheStorageImpl* storage, const GURL& url, int64 cache_id) 962 AppCacheStorageImpl* storage, const GURL& url, int64 cache_id)
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 } 1364 }
1366 1365
1367 void AppCacheStorageImpl::DeliverShortCircuitedFindMainResponse( 1366 void AppCacheStorageImpl::DeliverShortCircuitedFindMainResponse(
1368 const GURL& url, 1367 const GURL& url,
1369 const AppCacheEntry& found_entry, 1368 const AppCacheEntry& found_entry,
1370 scoped_refptr<AppCacheGroup> group, 1369 scoped_refptr<AppCacheGroup> group,
1371 scoped_refptr<AppCache> cache, 1370 scoped_refptr<AppCache> cache,
1372 scoped_refptr<DelegateReference> delegate_ref) { 1371 scoped_refptr<DelegateReference> delegate_ref) {
1373 if (delegate_ref->delegate) { 1372 if (delegate_ref->delegate) {
1374 DelegateReferenceVector delegates(1, delegate_ref); 1373 DelegateReferenceVector delegates(1, delegate_ref);
1375 CheckPolicyAndCallOnMainResponseFound( 1374 CallOnMainResponseFound(
1376 &delegates, url, found_entry, 1375 &delegates, url, found_entry,
1377 GURL(), AppCacheEntry(), 1376 GURL(), AppCacheEntry(),
1378 cache.get() ? cache->cache_id() : kNoCacheId, 1377 cache.get() ? cache->cache_id() : kNoCacheId,
1379 group.get() ? group->manifest_url() : GURL()); 1378 group.get() ? group->manifest_url() : GURL());
1380 } 1379 }
1381 } 1380 }
1382 1381
1383 void AppCacheStorageImpl::CheckPolicyAndCallOnMainResponseFound( 1382 void AppCacheStorageImpl::CallOnMainResponseFound(
1384 DelegateReferenceVector* delegates, 1383 DelegateReferenceVector* delegates,
1385 const GURL& url, const AppCacheEntry& entry, 1384 const GURL& url, const AppCacheEntry& entry,
1386 const GURL& fallback_url, const AppCacheEntry& fallback_entry, 1385 const GURL& fallback_url, const AppCacheEntry& fallback_entry,
1387 int64 cache_id, const GURL& manifest_url) { 1386 int64 cache_id, const GURL& manifest_url) {
1388 if (!manifest_url.is_empty()) {
1389 // Check the policy prior to returning a main resource from the appcache.
1390 AppCachePolicy* policy = service()->appcache_policy();
1391 if (policy && !policy->CanLoadAppCache(manifest_url)) {
1392 FOR_EACH_DELEGATE(
1393 (*delegates),
1394 OnMainResponseFound(url, AppCacheEntry(),
1395 GURL(), AppCacheEntry(),
1396 kNoCacheId, manifest_url, true));
1397 return;
1398 }
1399 }
1400
1401 FOR_EACH_DELEGATE( 1387 FOR_EACH_DELEGATE(
1402 (*delegates), 1388 (*delegates),
1403 OnMainResponseFound(url, entry, 1389 OnMainResponseFound(url, entry,
1404 fallback_url, fallback_entry, 1390 fallback_url, fallback_entry,
1405 cache_id, manifest_url, false)); 1391 cache_id, manifest_url));
1406 } 1392 }
1407 1393
1408 void AppCacheStorageImpl::FindResponseForSubRequest( 1394 void AppCacheStorageImpl::FindResponseForSubRequest(
1409 AppCache* cache, const GURL& url, 1395 AppCache* cache, const GURL& url,
1410 AppCacheEntry* found_entry, AppCacheEntry* found_fallback_entry, 1396 AppCacheEntry* found_entry, AppCacheEntry* found_fallback_entry,
1411 bool* found_network_namespace) { 1397 bool* found_network_namespace) {
1412 DCHECK(cache && cache->is_complete()); 1398 DCHECK(cache && cache->is_complete());
1413 1399
1414 // When a group is forcibly deleted, all subresource loads for pages 1400 // When a group is forcibly deleted, all subresource loads for pages
1415 // using caches in the group will result in a synthesized network errors. 1401 // using caches in the group will result in a synthesized network errors.
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 Disable(); 1635 Disable();
1650 if (!is_incognito_) { 1636 if (!is_incognito_) {
1651 VLOG(1) << "Deleting existing appcache data and starting over."; 1637 VLOG(1) << "Deleting existing appcache data and starting over.";
1652 AppCacheThread::PostTask(AppCacheThread::db(), FROM_HERE, 1638 AppCacheThread::PostTask(AppCacheThread::db(), FROM_HERE,
1653 NewRunnableFunction(DeleteDirectory, cache_directory_)); 1639 NewRunnableFunction(DeleteDirectory, cache_directory_));
1654 } 1640 }
1655 } 1641 }
1656 } 1642 }
1657 1643
1658 } // namespace appcache 1644 } // namespace appcache
OLDNEW
« no previous file with comments | « webkit/appcache/appcache_storage_impl.h ('k') | webkit/appcache/appcache_storage_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698