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

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

Issue 2930183002: Let IndexedDBContextImpl create its own task runner (Closed)
Patch Set: Use ScopedTaskEnvironment for most tests Created 3 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
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/command_line.h" 13 #include "base/command_line.h"
14 #include "base/location.h" 14 #include "base/location.h"
15 #include "base/sequenced_task_runner.h" 15 #include "base/sequenced_task_runner.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "base/task_scheduler/post_task.h"
19 #include "content/browser/blob_storage/chrome_blob_storage_context.h" 18 #include "content/browser/blob_storage/chrome_blob_storage_context.h"
20 #include "content/browser/browser_main_loop.h" 19 #include "content/browser/browser_main_loop.h"
21 #include "content/browser/browsing_data/storage_partition_http_cache_data_remove r.h" 20 #include "content/browser/browsing_data/storage_partition_http_cache_data_remove r.h"
22 #include "content/browser/fileapi/browser_file_system_helper.h" 21 #include "content/browser/fileapi/browser_file_system_helper.h"
23 #include "content/browser/gpu/shader_cache_factory.h" 22 #include "content/browser/gpu/shader_cache_factory.h"
24 #include "content/browser/notifications/platform_notification_context_impl.h" 23 #include "content/browser/notifications/platform_notification_context_impl.h"
25 #include "content/common/dom_storage/dom_storage_types.h" 24 #include "content/common/dom_storage/dom_storage_types.h"
26 #include "content/public/browser/browser_context.h" 25 #include "content/public/browser/browser_context.h"
27 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/content_browser_client.h" 27 #include "content/public/browser/content_browser_client.h"
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 partition->database_tracker_ = new storage::DatabaseTracker( 464 partition->database_tracker_ = new storage::DatabaseTracker(
466 partition_path, in_memory, context->GetSpecialStoragePolicy(), 465 partition_path, in_memory, context->GetSpecialStoragePolicy(),
467 quota_manager_proxy.get(), 466 quota_manager_proxy.get(),
468 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get()); 467 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get());
469 468
470 partition->dom_storage_context_ = new DOMStorageContextWrapper( 469 partition->dom_storage_context_ = new DOMStorageContextWrapper(
471 BrowserContext::GetConnectorFor(context), 470 BrowserContext::GetConnectorFor(context),
472 in_memory ? base::FilePath() : context->GetPath(), 471 in_memory ? base::FilePath() : context->GetPath(),
473 relative_partition_path, context->GetSpecialStoragePolicy()); 472 relative_partition_path, context->GetSpecialStoragePolicy());
474 473
475 // BrowserMainLoop may not be initialized in unit tests. Tests will
476 // need to inject their own task runner into the IndexedDBContext.
477 // TODO(jsbell): This is no longer true, update tests to provide use a
478 // base::test::ScopedTaskEnvironment instead of injecting a test task
479 // runner.
480 scoped_refptr<base::SequencedTaskRunner> idb_task_runner =
481 BrowserThread::CurrentlyOn(BrowserThread::UI) &&
482 BrowserMainLoop::GetInstance()
483 ? base::CreateSequencedTaskRunnerWithTraits({
484 base::MayBlock(), base::WithBaseSyncPrimitives(),
485 base::TaskPriority::USER_VISIBLE,
486 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN,
487 })
488 : nullptr;
489
490 base::FilePath path = in_memory ? base::FilePath() : partition_path; 474 base::FilePath path = in_memory ? base::FilePath() : partition_path;
491 partition->indexed_db_context_ = 475 partition->indexed_db_context_ = new IndexedDBContextImpl(
492 new IndexedDBContextImpl(path, context->GetSpecialStoragePolicy(), 476 path, context->GetSpecialStoragePolicy(), quota_manager_proxy.get());
493 quota_manager_proxy.get(), idb_task_runner);
494 477
495 partition->cache_storage_context_ = new CacheStorageContextImpl(context); 478 partition->cache_storage_context_ = new CacheStorageContextImpl(context);
496 partition->cache_storage_context_->Init(path, quota_manager_proxy); 479 partition->cache_storage_context_->Init(path, quota_manager_proxy);
497 480
498 partition->service_worker_context_ = new ServiceWorkerContextWrapper(context); 481 partition->service_worker_context_ = new ServiceWorkerContextWrapper(context);
499 partition->service_worker_context_->Init(path, quota_manager_proxy.get(), 482 partition->service_worker_context_->Init(path, quota_manager_proxy.get(),
500 context->GetSpecialStoragePolicy()); 483 context->GetSpecialStoragePolicy());
501 partition->service_worker_context_->set_storage_partition(partition.get()); 484 partition->service_worker_context_->set_storage_partition(partition.get());
502 485
503 partition->appcache_service_ = 486 partition->appcache_service_ =
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 media_url_request_context_ = media_url_request_context; 969 media_url_request_context_ = media_url_request_context;
987 } 970 }
988 971
989 void StoragePartitionImpl::GetQuotaSettings( 972 void StoragePartitionImpl::GetQuotaSettings(
990 const storage::OptionalQuotaSettingsCallback& callback) { 973 const storage::OptionalQuotaSettingsCallback& callback) {
991 GetContentClient()->browser()->GetQuotaSettings(browser_context_, this, 974 GetContentClient()->browser()->GetQuotaSettings(browser_context_, this,
992 callback); 975 callback);
993 } 976 }
994 977
995 } // namespace content 978 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698