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

Side by Side Diff: content/browser/appcache/appcache_storage_impl.cc

Issue 2040833002: AppCache: Add nullptr check where AppCacheStorageImpl::disk_cache() is called (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « content/browser/appcache/appcache_storage_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/appcache/appcache_storage_impl.h" 5 #include "content/browser/appcache/appcache_storage_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <functional> 10 #include <functional>
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after
1728 1728
1729 void AppCacheStorageImpl::StoreEvictionTimes(AppCacheGroup* group) { 1729 void AppCacheStorageImpl::StoreEvictionTimes(AppCacheGroup* group) {
1730 scoped_refptr<UpdateEvictionTimesTask> task( 1730 scoped_refptr<UpdateEvictionTimesTask> task(
1731 new UpdateEvictionTimesTask(this, group)); 1731 new UpdateEvictionTimesTask(this, group));
1732 task->Schedule(); 1732 task->Schedule();
1733 } 1733 }
1734 1734
1735 AppCacheResponseReader* AppCacheStorageImpl::CreateResponseReader( 1735 AppCacheResponseReader* AppCacheStorageImpl::CreateResponseReader(
1736 const GURL& manifest_url, 1736 const GURL& manifest_url,
1737 int64_t response_id) { 1737 int64_t response_id) {
1738 return new AppCacheResponseReader(response_id, disk_cache()->GetWeakPtr()); 1738 return new AppCacheResponseReader(
1739 response_id, is_disabled_ ? nullptr : disk_cache()->GetWeakPtr());
1739 } 1740 }
1740 1741
1741 AppCacheResponseWriter* AppCacheStorageImpl::CreateResponseWriter( 1742 AppCacheResponseWriter* AppCacheStorageImpl::CreateResponseWriter(
1742 const GURL& manifest_url) { 1743 const GURL& manifest_url) {
1743 return new AppCacheResponseWriter(NewResponseId(), 1744 return new AppCacheResponseWriter(
1744 disk_cache()->GetWeakPtr()); 1745 NewResponseId(), is_disabled_ ? nullptr : disk_cache()->GetWeakPtr());
1745 } 1746 }
1746 1747
1747 AppCacheResponseMetadataWriter* 1748 AppCacheResponseMetadataWriter*
1748 AppCacheStorageImpl::CreateResponseMetadataWriter(int64_t response_id) { 1749 AppCacheStorageImpl::CreateResponseMetadataWriter(int64_t response_id) {
1749 return new AppCacheResponseMetadataWriter(response_id, 1750 return new AppCacheResponseMetadataWriter(
1750 disk_cache()->GetWeakPtr()); 1751 response_id, is_disabled_ ? nullptr : disk_cache()->GetWeakPtr());
1751 } 1752 }
1752 1753
1753 void AppCacheStorageImpl::DoomResponses( 1754 void AppCacheStorageImpl::DoomResponses(
1754 const GURL& manifest_url, 1755 const GURL& manifest_url,
1755 const std::vector<int64_t>& response_ids) { 1756 const std::vector<int64_t>& response_ids) {
1756 if (response_ids.empty()) 1757 if (response_ids.empty())
1757 return; 1758 return;
1758 1759
1759 // Start deleting them from the disk cache lazily. 1760 // Start deleting them from the disk cache lazily.
1760 StartDeletingResponses(response_ids); 1761 StartDeletingResponses(response_ids);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1805 FROM_HERE, base::Bind(&AppCacheStorageImpl::DeleteOneResponse, 1806 FROM_HERE, base::Bind(&AppCacheStorageImpl::DeleteOneResponse,
1806 weak_factory_.GetWeakPtr()), 1807 weak_factory_.GetWeakPtr()),
1807 kBriefDelay); 1808 kBriefDelay);
1808 is_response_deletion_scheduled_ = true; 1809 is_response_deletion_scheduled_ = true;
1809 } 1810 }
1810 1811
1811 void AppCacheStorageImpl::DeleteOneResponse() { 1812 void AppCacheStorageImpl::DeleteOneResponse() {
1812 DCHECK(is_response_deletion_scheduled_); 1813 DCHECK(is_response_deletion_scheduled_);
1813 DCHECK(!deletable_response_ids_.empty()); 1814 DCHECK(!deletable_response_ids_.empty());
1814 1815
1815 if (!disk_cache()) { 1816 if (is_disabled_) {
kinuko 2016/06/06 04:06:17 nit: !disk_cache() and is_disabled_ seems to have
nhiroki 2016/06/06 04:41:35 disk_cache() returns nullptr only if is_disabled_
kinuko 2016/06/06 04:56:21 It seems to mean disk_cache() has side-effect, is
nhiroki 2016/06/06 06:04:17 Ohh, good point! I'm not 100% sure that disk_cache
1816 DCHECK(is_disabled_);
1817 deletable_response_ids_.clear(); 1817 deletable_response_ids_.clear();
1818 deleted_response_ids_.clear(); 1818 deleted_response_ids_.clear();
1819 is_response_deletion_scheduled_ = false; 1819 is_response_deletion_scheduled_ = false;
1820 return; 1820 return;
1821 } 1821 }
1822 1822
1823 // TODO(michaeln): add group_id to DoomEntry args 1823 // TODO(michaeln): add group_id to DoomEntry args
1824 int64_t id = deletable_response_ids_.front(); 1824 int64_t id = deletable_response_ids_.front();
1825 int rv = disk_cache_->DoomEntry( 1825 int rv = disk_cache_->DoomEntry(
1826 id, base::Bind(&AppCacheStorageImpl::OnDeletedOneResponse, 1826 id, base::Bind(&AppCacheStorageImpl::OnDeletedOneResponse,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 1894
1895 void AppCacheStorageImpl::RunOnePendingSimpleTask() { 1895 void AppCacheStorageImpl::RunOnePendingSimpleTask() {
1896 DCHECK(!pending_simple_tasks_.empty()); 1896 DCHECK(!pending_simple_tasks_.empty());
1897 base::Closure task = pending_simple_tasks_.front(); 1897 base::Closure task = pending_simple_tasks_.front();
1898 pending_simple_tasks_.pop_front(); 1898 pending_simple_tasks_.pop_front();
1899 task.Run(); 1899 task.Run();
1900 } 1900 }
1901 1901
1902 AppCacheDiskCache* AppCacheStorageImpl::disk_cache() { 1902 AppCacheDiskCache* AppCacheStorageImpl::disk_cache() {
1903 DCHECK(IsInitTaskComplete()); 1903 DCHECK(IsInitTaskComplete());
1904 1904 DCHECK(!is_disabled_);
1905 if (is_disabled_)
1906 return NULL;
1907 1905
1908 if (!disk_cache_) { 1906 if (!disk_cache_) {
1909 int rv = net::OK; 1907 int rv = net::OK;
1910 disk_cache_.reset(new AppCacheDiskCache); 1908 disk_cache_.reset(new AppCacheDiskCache);
1911 if (is_incognito_) { 1909 if (is_incognito_) {
1912 rv = disk_cache_->InitWithMemBackend( 1910 rv = disk_cache_->InitWithMemBackend(
1913 kMaxMemDiskCacheSize, 1911 kMaxMemDiskCacheSize,
1914 base::Bind(&AppCacheStorageImpl::OnDiskCacheInitialized, 1912 base::Bind(&AppCacheStorageImpl::OnDiskCacheInitialized,
1915 base::Unretained(this))); 1913 base::Unretained(this)));
1916 } else { 1914 } else {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1983 1981
1984 void AppCacheStorageImpl::OnLazyCommitTimer() { 1982 void AppCacheStorageImpl::OnLazyCommitTimer() {
1985 lazy_commit_timer_.Stop(); 1983 lazy_commit_timer_.Stop();
1986 if (is_disabled()) 1984 if (is_disabled())
1987 return; 1985 return;
1988 scoped_refptr<DatabaseTask> task(new CommitLastAccessTimesTask(this)); 1986 scoped_refptr<DatabaseTask> task(new CommitLastAccessTimesTask(this));
1989 task->Schedule(); 1987 task->Schedule();
1990 } 1988 }
1991 1989
1992 } // namespace content 1990 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/appcache/appcache_storage_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698