| OLD | NEW |
| 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 "webkit/appcache/appcache_storage_impl.h" | 5 #include "webkit/appcache/appcache_storage_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 | 417 |
| 418 void AppCacheStorageImpl::StoreOrLoadTask::CreateCacheAndGroupFromRecords( | 418 void AppCacheStorageImpl::StoreOrLoadTask::CreateCacheAndGroupFromRecords( |
| 419 scoped_refptr<AppCache>* cache, scoped_refptr<AppCacheGroup>* group) { | 419 scoped_refptr<AppCache>* cache, scoped_refptr<AppCacheGroup>* group) { |
| 420 DCHECK(storage_ && cache && group); | 420 DCHECK(storage_ && cache && group); |
| 421 | 421 |
| 422 (*cache) = storage_->working_set_.GetCache(cache_record_.cache_id); | 422 (*cache) = storage_->working_set_.GetCache(cache_record_.cache_id); |
| 423 if (cache->get()) { | 423 if (cache->get()) { |
| 424 (*group) = cache->get()->owning_group(); | 424 (*group) = cache->get()->owning_group(); |
| 425 DCHECK(group->get()); | 425 DCHECK(group->get()); |
| 426 DCHECK_EQ(group_record_.group_id, group->get()->group_id()); | 426 DCHECK_EQ(group_record_.group_id, group->get()->group_id()); |
| 427 |
| 428 // TODO(michaeln): histogram is fishing for clues to crbug/95101 |
| 429 if (!cache->get()->GetEntry(group_record_.manifest_url)) { |
| 430 AppCacheHistograms::AddMissingManifestDetectedAtCallsite( |
| 431 AppCacheHistograms::CALLSITE_0); |
| 432 } |
| 433 |
| 427 storage_->NotifyStorageAccessed(group_record_.origin); | 434 storage_->NotifyStorageAccessed(group_record_.origin); |
| 428 return; | 435 return; |
| 429 } | 436 } |
| 430 | 437 |
| 431 (*cache) = new AppCache(storage_->service_, cache_record_.cache_id); | 438 (*cache) = new AppCache(storage_->service_, cache_record_.cache_id); |
| 432 cache->get()->InitializeWithDatabaseRecords( | 439 cache->get()->InitializeWithDatabaseRecords( |
| 433 cache_record_, entry_records_, | 440 cache_record_, entry_records_, |
| 434 intercept_namespace_records_, | 441 intercept_namespace_records_, |
| 435 fallback_namespace_records_, | 442 fallback_namespace_records_, |
| 436 online_whitelist_records_); | 443 online_whitelist_records_); |
| 437 cache->get()->set_complete(true); | 444 cache->get()->set_complete(true); |
| 438 | 445 |
| 439 (*group) = storage_->working_set_.GetGroup(group_record_.manifest_url); | 446 (*group) = storage_->working_set_.GetGroup(group_record_.manifest_url); |
| 440 if (group->get()) { | 447 if (group->get()) { |
| 441 DCHECK(group_record_.group_id == group->get()->group_id()); | 448 DCHECK(group_record_.group_id == group->get()->group_id()); |
| 442 group->get()->AddCache(cache->get()); | 449 group->get()->AddCache(cache->get()); |
| 450 |
| 451 // TODO(michaeln): histogram is fishing for clues to crbug/95101 |
| 452 if (!cache->get()->GetEntry(group_record_.manifest_url)) { |
| 453 AppCacheHistograms::AddMissingManifestDetectedAtCallsite( |
| 454 AppCacheHistograms::CALLSITE_1); |
| 455 } |
| 443 } else { | 456 } else { |
| 444 (*group) = new AppCacheGroup( | 457 (*group) = new AppCacheGroup( |
| 445 storage_->service_, group_record_.manifest_url, | 458 storage_->service_, group_record_.manifest_url, |
| 446 group_record_.group_id); | 459 group_record_.group_id); |
| 447 group->get()->set_creation_time(group_record_.creation_time); | 460 group->get()->set_creation_time(group_record_.creation_time); |
| 448 group->get()->AddCache(cache->get()); | 461 group->get()->AddCache(cache->get()); |
| 462 |
| 463 // TODO(michaeln): histogram is fishing for clues to crbug/95101 |
| 464 if (!cache->get()->GetEntry(group_record_.manifest_url)) { |
| 465 AppCacheHistograms::AddMissingManifestDetectedAtCallsite( |
| 466 AppCacheHistograms::CALLSITE_2); |
| 467 } |
| 449 } | 468 } |
| 450 DCHECK(group->get()->newest_complete_cache() == cache->get()); | 469 DCHECK(group->get()->newest_complete_cache() == cache->get()); |
| 451 | 470 |
| 452 // We have to update foriegn entries if MarkEntryAsForeignTasks | 471 // We have to update foriegn entries if MarkEntryAsForeignTasks |
| 453 // are in flight. | 472 // are in flight. |
| 454 std::vector<GURL> urls; | 473 std::vector<GURL> urls; |
| 455 storage_->GetPendingForeignMarkingsForCache(cache->get()->cache_id(), &urls); | 474 storage_->GetPendingForeignMarkingsForCache(cache->get()->cache_id(), &urls); |
| 456 for (std::vector<GURL>::iterator iter = urls.begin(); | 475 for (std::vector<GURL>::iterator iter = urls.begin(); |
| 457 iter != urls.end(); ++iter) { | 476 iter != urls.end(); ++iter) { |
| 458 DCHECK(cache->get()->GetEntry(*iter)); | 477 DCHECK(cache->get()->GetEntry(*iter)); |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 // TODO(michaeln): distinguish between a simple update of an existing | 1435 // TODO(michaeln): distinguish between a simple update of an existing |
| 1417 // cache that just adds new master entry(s), and the insertion of a | 1436 // cache that just adds new master entry(s), and the insertion of a |
| 1418 // whole new cache. The StoreGroupAndCacheTask as written will handle | 1437 // whole new cache. The StoreGroupAndCacheTask as written will handle |
| 1419 // the simple update case in a very heavy weight way (delete all and | 1438 // the simple update case in a very heavy weight way (delete all and |
| 1420 // the reinsert all over again). | 1439 // the reinsert all over again). |
| 1421 DCHECK(group && delegate && newest_cache); | 1440 DCHECK(group && delegate && newest_cache); |
| 1422 scoped_refptr<StoreGroupAndCacheTask> task( | 1441 scoped_refptr<StoreGroupAndCacheTask> task( |
| 1423 new StoreGroupAndCacheTask(this, group, newest_cache)); | 1442 new StoreGroupAndCacheTask(this, group, newest_cache)); |
| 1424 task->AddDelegate(GetOrCreateDelegateReference(delegate)); | 1443 task->AddDelegate(GetOrCreateDelegateReference(delegate)); |
| 1425 task->GetQuotaThenSchedule(); | 1444 task->GetQuotaThenSchedule(); |
| 1445 |
| 1446 // TODO(michaeln): histogram is fishing for clues to crbug/95101 |
| 1447 if (!newest_cache->GetEntry(group->manifest_url())) { |
| 1448 AppCacheHistograms::AddMissingManifestDetectedAtCallsite( |
| 1449 AppCacheHistograms::CALLSITE_3); |
| 1450 } |
| 1426 } | 1451 } |
| 1427 | 1452 |
| 1428 void AppCacheStorageImpl::FindResponseForMainRequest( | 1453 void AppCacheStorageImpl::FindResponseForMainRequest( |
| 1429 const GURL& url, const GURL& preferred_manifest_url, | 1454 const GURL& url, const GURL& preferred_manifest_url, |
| 1430 Delegate* delegate) { | 1455 Delegate* delegate) { |
| 1431 DCHECK(delegate); | 1456 DCHECK(delegate); |
| 1432 | 1457 |
| 1433 const GURL* url_ptr = &url; | 1458 const GURL* url_ptr = &url; |
| 1434 GURL url_no_ref; | 1459 GURL url_no_ref; |
| 1435 if (url.has_ref()) { | 1460 if (url.has_ref()) { |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1788 Disable(); | 1813 Disable(); |
| 1789 if (!is_incognito_) { | 1814 if (!is_incognito_) { |
| 1790 VLOG(1) << "Deleting existing appcache data and starting over."; | 1815 VLOG(1) << "Deleting existing appcache data and starting over."; |
| 1791 db_thread_->PostTask( | 1816 db_thread_->PostTask( |
| 1792 FROM_HERE, base::Bind(&DeleteDirectory, cache_directory_)); | 1817 FROM_HERE, base::Bind(&DeleteDirectory, cache_directory_)); |
| 1793 } | 1818 } |
| 1794 } | 1819 } |
| 1795 } | 1820 } |
| 1796 | 1821 |
| 1797 } // namespace appcache | 1822 } // namespace appcache |
| OLD | NEW |