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

Side by Side Diff: content/browser/storage_partition_impl.cc

Issue 1782053004: Change how the quota system computes the total poolsize for temporary storage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 3 years, 10 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/storage_partition_impl.h ('k') | content/browser/storage_partition_impl_map.cc » ('j') | 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/storage_partition_impl.h" 5 #include "content/browser/storage_partition_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/sequenced_task_runner.h" 14 #include "base/sequenced_task_runner.h"
15 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "content/browser/browser_main_loop.h" 17 #include "content/browser/browser_main_loop.h"
18 #include "content/browser/fileapi/browser_file_system_helper.h" 18 #include "content/browser/fileapi/browser_file_system_helper.h"
19 #include "content/browser/gpu/shader_cache_factory.h" 19 #include "content/browser/gpu/shader_cache_factory.h"
20 #include "content/browser/host_zoom_map_impl.h" 20 #include "content/browser/host_zoom_map_impl.h"
21 #include "content/browser/notifications/platform_notification_context_impl.h" 21 #include "content/browser/notifications/platform_notification_context_impl.h"
22 #include "content/common/dom_storage/dom_storage_types.h" 22 #include "content/common/dom_storage/dom_storage_types.h"
23 #include "content/public/browser/browser_context.h" 23 #include "content/public/browser/browser_context.h"
24 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/content_browser_client.h"
25 #include "content/public/browser/dom_storage_context.h" 26 #include "content/public/browser/dom_storage_context.h"
26 #include "content/public/browser/indexed_db_context.h" 27 #include "content/public/browser/indexed_db_context.h"
27 #include "content/public/browser/local_storage_usage_info.h" 28 #include "content/public/browser/local_storage_usage_info.h"
28 #include "content/public/browser/session_storage_usage_info.h" 29 #include "content/public/browser/session_storage_usage_info.h"
30 #include "content/public/common/content_client.h"
29 #include "net/base/completion_callback.h" 31 #include "net/base/completion_callback.h"
30 #include "net/base/net_errors.h" 32 #include "net/base/net_errors.h"
31 #include "net/cookies/canonical_cookie.h" 33 #include "net/cookies/canonical_cookie.h"
32 #include "net/cookies/cookie_monster.h" 34 #include "net/cookies/cookie_monster.h"
33 #include "net/url_request/url_request_context.h" 35 #include "net/url_request/url_request_context.h"
34 #include "net/url_request/url_request_context_getter.h" 36 #include "net/url_request/url_request_context_getter.h"
35 #include "ppapi/features/features.h" 37 #include "ppapi/features/features.h"
36 #include "storage/browser/database/database_tracker.h" 38 #include "storage/browser/database/database_tracker.h"
37 #include "storage/browser/quota/quota_manager.h" 39 #include "storage/browser/quota/quota_manager.h"
38 40
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 quota_storage_remove_mask, 358 quota_storage_remove_mask,
357 storage_origin, 359 storage_origin,
358 callback); 360 callback);
359 helper->ClearDataOnIOThread(quota_manager, begin, special_storage_policy, 361 helper->ClearDataOnIOThread(quota_manager, begin, special_storage_policy,
360 origin_matcher); 362 origin_matcher);
361 } 363 }
362 364
363 StoragePartitionImpl::StoragePartitionImpl( 365 StoragePartitionImpl::StoragePartitionImpl(
364 BrowserContext* browser_context, 366 BrowserContext* browser_context,
365 const base::FilePath& partition_path, 367 const base::FilePath& partition_path,
366 storage::QuotaManager* quota_manager, 368 storage::SpecialStoragePolicy* special_storage_policy)
367 ChromeAppCacheService* appcache_service,
368 storage::FileSystemContext* filesystem_context,
369 storage::DatabaseTracker* database_tracker,
370 DOMStorageContextWrapper* dom_storage_context,
371 IndexedDBContextImpl* indexed_db_context,
372 CacheStorageContextImpl* cache_storage_context,
373 ServiceWorkerContextWrapper* service_worker_context,
374 PushMessagingContext* push_messaging_context,
375 storage::SpecialStoragePolicy* special_storage_policy,
376 HostZoomLevelContext* host_zoom_level_context,
377 PlatformNotificationContextImpl* platform_notification_context,
378 BackgroundSyncContext* background_sync_context,
379 PaymentAppContextImpl* payment_app_context,
380 scoped_refptr<BroadcastChannelProvider> broadcast_channel_provider)
381 : partition_path_(partition_path), 369 : partition_path_(partition_path),
382 quota_manager_(quota_manager),
383 appcache_service_(appcache_service),
384 filesystem_context_(filesystem_context),
385 database_tracker_(database_tracker),
386 dom_storage_context_(dom_storage_context),
387 indexed_db_context_(indexed_db_context),
388 cache_storage_context_(cache_storage_context),
389 service_worker_context_(service_worker_context),
390 push_messaging_context_(push_messaging_context),
391 special_storage_policy_(special_storage_policy), 370 special_storage_policy_(special_storage_policy),
392 host_zoom_level_context_(host_zoom_level_context), 371 browser_context_(browser_context),
393 platform_notification_context_(platform_notification_context), 372 weak_factory_(this) {}
394 background_sync_context_(background_sync_context),
395 payment_app_context_(payment_app_context),
396 broadcast_channel_provider_(std::move(broadcast_channel_provider)),
397 browser_context_(browser_context) {}
398 373
399 StoragePartitionImpl::~StoragePartitionImpl() { 374 StoragePartitionImpl::~StoragePartitionImpl() {
400 browser_context_ = nullptr; 375 browser_context_ = nullptr;
401 376
402 // These message loop checks are just to avoid leaks in unittests. 377 // These message loop checks are just to avoid leaks in unittests.
403 if (GetDatabaseTracker() && 378 if (GetDatabaseTracker() &&
404 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { 379 BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) {
405 BrowserThread::PostTask( 380 BrowserThread::PostTask(
406 BrowserThread::FILE, 381 BrowserThread::FILE,
407 FROM_HERE, 382 FROM_HERE,
(...skipping 28 matching lines...) Expand all
436 bool in_memory, 411 bool in_memory,
437 const base::FilePath& relative_partition_path) { 412 const base::FilePath& relative_partition_path) {
438 // Ensure that these methods are called on the UI thread, except for 413 // Ensure that these methods are called on the UI thread, except for
439 // unittests where a UI thread might not have been created. 414 // unittests where a UI thread might not have been created.
440 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || 415 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
441 !BrowserThread::IsMessageLoopValid(BrowserThread::UI)); 416 !BrowserThread::IsMessageLoopValid(BrowserThread::UI));
442 417
443 base::FilePath partition_path = 418 base::FilePath partition_path =
444 context->GetPath().Append(relative_partition_path); 419 context->GetPath().Append(relative_partition_path);
445 420
421 std::unique_ptr<StoragePartitionImpl> partition =
422 base::WrapUnique(new StoragePartitionImpl(
423 context, partition_path, context->GetSpecialStoragePolicy()));
424
446 // All of the clients have to be created and registered with the 425 // All of the clients have to be created and registered with the
447 // QuotaManager prior to the QuotaManger being used. We do them 426 // QuotaManager prior to the QuotaManger being used. We do them
448 // all together here prior to handing out a reference to anything 427 // all together here prior to handing out a reference to anything
449 // that utilizes the QuotaManager. 428 // that utilizes the QuotaManager.
450 scoped_refptr<storage::QuotaManager> quota_manager = 429 partition->quota_manager_ = new storage::QuotaManager(
451 new storage::QuotaManager( 430 in_memory, partition_path,
452 in_memory, partition_path, 431 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO).get(),
453 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO).get(), 432 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB).get(),
454 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB).get(), 433 context->GetSpecialStoragePolicy(),
455 context->GetSpecialStoragePolicy()); 434 base::Bind(&StoragePartitionImpl::GetQuotaSettings,
435 partition->weak_factory_.GetWeakPtr()));
436 scoped_refptr<storage::QuotaManagerProxy> quota_manager_proxy =
437 partition->quota_manager_->proxy();
456 438
457 // Each consumer is responsible for registering its QuotaClient during 439 // Each consumer is responsible for registering its QuotaClient during
458 // its construction. 440 // its construction.
459 scoped_refptr<storage::FileSystemContext> filesystem_context = 441 partition->filesystem_context_ = CreateFileSystemContext(
460 CreateFileSystemContext( 442 context, partition_path, in_memory, quota_manager_proxy.get());
461 context, partition_path, in_memory, quota_manager->proxy());
462 443
463 scoped_refptr<storage::DatabaseTracker> database_tracker = 444 partition->database_tracker_ = new storage::DatabaseTracker(
464 new storage::DatabaseTracker( 445 partition_path, in_memory, context->GetSpecialStoragePolicy(),
465 partition_path, in_memory, context->GetSpecialStoragePolicy(), 446 quota_manager_proxy.get(),
466 quota_manager->proxy(), 447 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get());
467 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get());
468 448
469 scoped_refptr<DOMStorageContextWrapper> dom_storage_context = 449 partition->dom_storage_context_ = new DOMStorageContextWrapper(
470 new DOMStorageContextWrapper( 450 BrowserContext::GetConnectorFor(context),
471 BrowserContext::GetConnectorFor(context), 451 in_memory ? base::FilePath() : context->GetPath(),
472 in_memory ? base::FilePath() : context->GetPath(), 452 relative_partition_path, context->GetSpecialStoragePolicy());
473 relative_partition_path, context->GetSpecialStoragePolicy());
474 453
475 // BrowserMainLoop may not be initialized in unit tests. Tests will 454 // BrowserMainLoop may not be initialized in unit tests. Tests will
476 // need to inject their own task runner into the IndexedDBContext. 455 // need to inject their own task runner into the IndexedDBContext.
477 base::SequencedTaskRunner* idb_task_runner = 456 base::SequencedTaskRunner* idb_task_runner =
478 BrowserThread::CurrentlyOn(BrowserThread::UI) && 457 BrowserThread::CurrentlyOn(BrowserThread::UI) &&
479 BrowserMainLoop::GetInstance() 458 BrowserMainLoop::GetInstance()
480 ? BrowserMainLoop::GetInstance() 459 ? BrowserMainLoop::GetInstance()
481 ->indexed_db_thread() 460 ->indexed_db_thread()
482 ->task_runner() 461 ->task_runner()
483 .get() 462 .get()
484 : NULL; 463 : NULL;
485 464
486 base::FilePath path = in_memory ? base::FilePath() : partition_path; 465 base::FilePath path = in_memory ? base::FilePath() : partition_path;
487 scoped_refptr<IndexedDBContextImpl> indexed_db_context = 466 partition->indexed_db_context_ =
488 new IndexedDBContextImpl(path, 467 new IndexedDBContextImpl(path, context->GetSpecialStoragePolicy(),
489 context->GetSpecialStoragePolicy(), 468 quota_manager_proxy.get(), idb_task_runner);
490 quota_manager->proxy(),
491 idb_task_runner);
492 469
493 scoped_refptr<CacheStorageContextImpl> cache_storage_context = 470 partition->cache_storage_context_ = new CacheStorageContextImpl(context);
494 new CacheStorageContextImpl(context); 471 partition->cache_storage_context_->Init(path, quota_manager_proxy);
495 cache_storage_context->Init(path, make_scoped_refptr(quota_manager->proxy()));
496 472
497 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context = 473 partition->service_worker_context_ = new ServiceWorkerContextWrapper(context);
498 new ServiceWorkerContextWrapper(context); 474 partition->service_worker_context_->Init(path, quota_manager_proxy.get(),
499 service_worker_context->Init(path, quota_manager->proxy(), 475 context->GetSpecialStoragePolicy());
500 context->GetSpecialStoragePolicy()); 476 partition->service_worker_context_->set_storage_partition(partition.get());
501 477
502 scoped_refptr<ChromeAppCacheService> appcache_service = 478 partition->appcache_service_ =
503 new ChromeAppCacheService(quota_manager->proxy()); 479 new ChromeAppCacheService(quota_manager_proxy.get());
504 480
505 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy( 481 partition->push_messaging_context_ =
506 context->GetSpecialStoragePolicy()); 482 new PushMessagingContext(context, partition->service_worker_context_);
507 483
508 scoped_refptr<PushMessagingContext> push_messaging_context( 484 partition->host_zoom_level_context_ = new HostZoomLevelContext(
509 new PushMessagingContext(context, service_worker_context)); 485 context->CreateZoomLevelDelegate(partition_path));
510 486
511 scoped_refptr<HostZoomLevelContext> host_zoom_level_context( 487 partition->platform_notification_context_ =
512 new HostZoomLevelContext( 488 new PlatformNotificationContextImpl(path, context,
513 context->CreateZoomLevelDelegate(partition_path))); 489 partition->service_worker_context_);
490 partition->platform_notification_context_->Initialize();
514 491
515 scoped_refptr<PlatformNotificationContextImpl> platform_notification_context = 492 partition->background_sync_context_ = new BackgroundSyncContext();
516 new PlatformNotificationContextImpl(path, context, 493 partition->background_sync_context_->Init(partition->service_worker_context_);
517 service_worker_context);
518 platform_notification_context->Initialize();
519 494
520 scoped_refptr<BackgroundSyncContext> background_sync_context = 495 partition->payment_app_context_ = new PaymentAppContextImpl();
521 new BackgroundSyncContext(); 496 partition->payment_app_context_->Init(partition->service_worker_context_);
522 background_sync_context->Init(service_worker_context);
523 497
524 scoped_refptr<PaymentAppContextImpl> payment_app_context = 498 partition->broadcast_channel_provider_ = new BroadcastChannelProvider();
525 new PaymentAppContextImpl();
526 payment_app_context->Init(service_worker_context);
527 499
528 scoped_refptr<BroadcastChannelProvider> 500 return partition;
529 broadcast_channel_provider = new BroadcastChannelProvider();
530
531 std::unique_ptr<StoragePartitionImpl> storage_partition(
532 new StoragePartitionImpl(
533 context, partition_path, quota_manager.get(), appcache_service.get(),
534 filesystem_context.get(), database_tracker.get(),
535 dom_storage_context.get(), indexed_db_context.get(),
536 cache_storage_context.get(), service_worker_context.get(),
537 push_messaging_context.get(), special_storage_policy.get(),
538 host_zoom_level_context.get(), platform_notification_context.get(),
539 background_sync_context.get(), payment_app_context.get(),
540 std::move(broadcast_channel_provider)));
541
542 service_worker_context->set_storage_partition(storage_partition.get());
543
544 return storage_partition;
545 } 501 }
546 502
547 base::FilePath StoragePartitionImpl::GetPath() { 503 base::FilePath StoragePartitionImpl::GetPath() {
548 return partition_path_; 504 return partition_path_;
549 } 505 }
550 506
551 net::URLRequestContextGetter* StoragePartitionImpl::GetURLRequestContext() { 507 net::URLRequestContextGetter* StoragePartitionImpl::GetURLRequestContext() {
552 return url_request_context_.get(); 508 return url_request_context_.get();
553 } 509 }
554 510
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 void StoragePartitionImpl::SetURLRequestContext( 888 void StoragePartitionImpl::SetURLRequestContext(
933 net::URLRequestContextGetter* url_request_context) { 889 net::URLRequestContextGetter* url_request_context) {
934 url_request_context_ = url_request_context; 890 url_request_context_ = url_request_context;
935 } 891 }
936 892
937 void StoragePartitionImpl::SetMediaURLRequestContext( 893 void StoragePartitionImpl::SetMediaURLRequestContext(
938 net::URLRequestContextGetter* media_url_request_context) { 894 net::URLRequestContextGetter* media_url_request_context) {
939 media_url_request_context_ = media_url_request_context; 895 media_url_request_context_ = media_url_request_context;
940 } 896 }
941 897
898 void StoragePartitionImpl::GetQuotaSettings(
899 const storage::OptionalQuotaSettingsCallback& callback) {
900 GetContentClient()->browser()->GetQuotaSettings(browser_context_, this,
901 callback);
902 }
903
942 } // namespace content 904 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/storage_partition_impl.h ('k') | content/browser/storage_partition_impl_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698