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

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

Issue 2867693004: Snapshot of all changes to get jumbo in blink and content.
Patch Set: Rebased again Created 3 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
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 27 matching lines...) Expand all
38 #include "storage/browser/quota/quota_client.h" 38 #include "storage/browser/quota/quota_client.h"
39 #include "storage/browser/quota/quota_manager.h" 39 #include "storage/browser/quota/quota_manager.h"
40 #include "storage/browser/quota/quota_manager_proxy.h" 40 #include "storage/browser/quota/quota_manager_proxy.h"
41 #include "storage/browser/quota/special_storage_policy.h" 41 #include "storage/browser/quota/special_storage_policy.h"
42 42
43 namespace content { 43 namespace content {
44 44
45 // Hard coded default when not using quota management. 45 // Hard coded default when not using quota management.
46 static const int kDefaultQuota = 5 * 1024 * 1024; 46 static const int kDefaultQuota = 5 * 1024 * 1024;
47 47
48 static const int kMaxDiskCacheSize = 250 * 1024 * 1024; 48 static const int kAppCacheMaxDiskCacheSize = 250 * 1024 * 1024;
49 static const int kMaxMemDiskCacheSize = 10 * 1024 * 1024; 49 static const int kAppCacheMaxMemDiskCacheSize = 10 * 1024 * 1024;
50 static const base::FilePath::CharType kDiskCacheDirectoryName[] = 50 static const base::FilePath::CharType kDiskCacheDirectoryName[] =
51 FILE_PATH_LITERAL("Cache"); 51 FILE_PATH_LITERAL("Cache");
52 52
53 namespace { 53 namespace {
54 54
55 // Helpers for clearing data from the AppCacheDatabase. 55 // Helpers for clearing data from the AppCacheDatabase.
56 bool DeleteGroupAndRelatedRecords( 56 bool DeleteGroupAndRelatedRecords(
57 AppCacheDatabase* database, 57 AppCacheDatabase* database,
58 int64_t group_id, 58 int64_t group_id,
59 std::vector<int64_t>* deletable_response_ids) { 59 std::vector<int64_t>* deletable_response_ids) {
(...skipping 11 matching lines...) Expand all
71 database->InsertDeletableResponseIds(*deletable_response_ids); 71 database->InsertDeletableResponseIds(*deletable_response_ids);
72 } else { 72 } else {
73 NOTREACHED() << "A existing group without a cache is unexpected"; 73 NOTREACHED() << "A existing group without a cache is unexpected";
74 success = database->DeleteGroup(group_id); 74 success = database->DeleteGroup(group_id);
75 } 75 }
76 return success; 76 return success;
77 } 77 }
78 78
79 // Destroys |database|. If there is appcache data to be deleted 79 // Destroys |database|. If there is appcache data to be deleted
80 // (|force_keep_session_state| is false), deletes session-only appcache data. 80 // (|force_keep_session_state| is false), deletes session-only appcache data.
81 void ClearSessionOnlyOrigins( 81 void AppCacheClearSessionOnlyOrigins(
82 AppCacheDatabase* database, 82 AppCacheDatabase* database,
83 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy, 83 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy,
84 bool force_keep_session_state) { 84 bool force_keep_session_state) {
85 std::unique_ptr<AppCacheDatabase> database_to_delete(database); 85 std::unique_ptr<AppCacheDatabase> database_to_delete(database);
86 86
87 // If saving session state, only delete the database. 87 // If saving session state, only delete the database.
88 if (force_keep_session_state) 88 if (force_keep_session_state)
89 return; 89 return;
90 90
91 bool has_session_only_appcaches = 91 bool has_session_only_appcaches =
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 1420
1421 AppCacheStorageImpl::~AppCacheStorageImpl() { 1421 AppCacheStorageImpl::~AppCacheStorageImpl() {
1422 for (auto* task : pending_quota_queries_) 1422 for (auto* task : pending_quota_queries_)
1423 task->CancelCompletion(); 1423 task->CancelCompletion();
1424 for (auto* task : scheduled_database_tasks_) 1424 for (auto* task : scheduled_database_tasks_)
1425 task->CancelCompletion(); 1425 task->CancelCompletion();
1426 1426
1427 if (database_ && 1427 if (database_ &&
1428 !db_task_runner_->PostTask( 1428 !db_task_runner_->PostTask(
1429 FROM_HERE, 1429 FROM_HERE,
1430 base::Bind(&ClearSessionOnlyOrigins, database_, 1430 base::Bind(&AppCacheClearSessionOnlyOrigins, database_,
1431 make_scoped_refptr(service_->special_storage_policy()), 1431 make_scoped_refptr(service_->special_storage_policy()),
1432 service()->force_keep_session_state()))) { 1432 service()->force_keep_session_state()))) {
1433 delete database_; 1433 delete database_;
1434 } 1434 }
1435 database_ = NULL; // So no further database tasks can be scheduled. 1435 database_ = NULL; // So no further database tasks can be scheduled.
1436 } 1436 }
1437 1437
1438 void AppCacheStorageImpl::Initialize( 1438 void AppCacheStorageImpl::Initialize(
1439 const base::FilePath& cache_directory, 1439 const base::FilePath& cache_directory,
1440 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, 1440 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 1903
1904 AppCacheDiskCache* AppCacheStorageImpl::disk_cache() { 1904 AppCacheDiskCache* AppCacheStorageImpl::disk_cache() {
1905 DCHECK(IsInitTaskComplete()); 1905 DCHECK(IsInitTaskComplete());
1906 DCHECK(!is_disabled_); 1906 DCHECK(!is_disabled_);
1907 1907
1908 if (!disk_cache_) { 1908 if (!disk_cache_) {
1909 int rv = net::OK; 1909 int rv = net::OK;
1910 disk_cache_.reset(new AppCacheDiskCache); 1910 disk_cache_.reset(new AppCacheDiskCache);
1911 if (is_incognito_) { 1911 if (is_incognito_) {
1912 rv = disk_cache_->InitWithMemBackend( 1912 rv = disk_cache_->InitWithMemBackend(
1913 kMaxMemDiskCacheSize, 1913 kAppCacheMaxMemDiskCacheSize,
1914 base::Bind(&AppCacheStorageImpl::OnDiskCacheInitialized, 1914 base::Bind(&AppCacheStorageImpl::OnDiskCacheInitialized,
1915 base::Unretained(this))); 1915 base::Unretained(this)));
1916 } else { 1916 } else {
1917 rv = disk_cache_->InitWithDiskBackend( 1917 rv = disk_cache_->InitWithDiskBackend(
1918 cache_directory_.Append(kDiskCacheDirectoryName), 1918 cache_directory_.Append(kDiskCacheDirectoryName),
1919 kMaxDiskCacheSize, 1919 kAppCacheMaxDiskCacheSize,
1920 false, 1920 false,
1921 cache_thread_.get(), 1921 cache_thread_.get(),
1922 base::Bind(&AppCacheStorageImpl::OnDiskCacheInitialized, 1922 base::Bind(&AppCacheStorageImpl::OnDiskCacheInitialized,
1923 base::Unretained(this))); 1923 base::Unretained(this)));
1924 } 1924 }
1925 1925
1926 if (rv != net::ERR_IO_PENDING) 1926 if (rv != net::ERR_IO_PENDING)
1927 OnDiskCacheInitialized(rv); 1927 OnDiskCacheInitialized(rv);
1928 } 1928 }
1929 return disk_cache_.get(); 1929 return disk_cache_.get();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1983 1983
1984 void AppCacheStorageImpl::OnLazyCommitTimer() { 1984 void AppCacheStorageImpl::OnLazyCommitTimer() {
1985 lazy_commit_timer_.Stop(); 1985 lazy_commit_timer_.Stop();
1986 if (is_disabled()) 1986 if (is_disabled())
1987 return; 1987 return;
1988 scoped_refptr<DatabaseTask> task(new CommitLastAccessTimesTask(this)); 1988 scoped_refptr<DatabaseTask> task(new CommitLastAccessTimesTask(this));
1989 task->Schedule(); 1989 task->Schedule();
1990 } 1990 }
1991 1991
1992 } // namespace content 1992 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/accessibility/accessibility_ui.cc ('k') | content/browser/appcache/appcache_update_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698