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 "content/browser/storage_partition_impl_map.h" | 5 #include "content/browser/storage_partition_impl_map.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
17 #include "content/browser/appcache/chrome_appcache_service.h" | 17 #include "content/browser/appcache/chrome_appcache_service.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/fileapi/chrome_blob_storage_context.h" | 19 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
20 #include "content/browser/loader/resource_request_info_impl.h" | 20 #include "content/browser/loader/resource_request_info_impl.h" |
21 #include "content/browser/resource_context_impl.h" | 21 #include "content/browser/resource_context_impl.h" |
22 #include "content/browser/storage_partition_impl.h" | 22 #include "content/browser/storage_partition_impl.h" |
23 #include "content/browser/streams/stream.h" | 23 #include "content/browser/streams/stream.h" |
24 #include "content/browser/streams/stream_context.h" | 24 #include "content/browser/streams/stream_context.h" |
25 #include "content/browser/streams/stream_registry.h" | 25 #include "content/browser/streams/stream_registry.h" |
26 #include "content/browser/streams/stream_url_request_job.h" | 26 #include "content/browser/streams/stream_url_request_job.h" |
27 #include "content/browser/webui/url_data_manager_backend.h" | 27 #include "content/browser/webui/url_data_manager_backend.h" |
| 28 #include "content/browser/worker_host/worker_storage_partition.h" |
28 #include "content/public/browser/browser_context.h" | 29 #include "content/public/browser/browser_context.h" |
29 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
30 #include "content/public/browser/content_browser_client.h" | 31 #include "content/public/browser/content_browser_client.h" |
31 #include "content/public/browser/storage_partition.h" | 32 #include "content/public/browser/storage_partition.h" |
32 #include "content/public/common/content_constants.h" | 33 #include "content/public/common/content_constants.h" |
33 #include "content/public/common/url_constants.h" | 34 #include "content/public/common/url_constants.h" |
34 #include "crypto/sha2.h" | 35 #include "crypto/sha2.h" |
35 #include "net/url_request/url_request_context.h" | 36 #include "net/url_request/url_request_context.h" |
36 #include "net/url_request/url_request_context_getter.h" | 37 #include "net/url_request/url_request_context_getter.h" |
37 #include "webkit/browser/blob/blob_storage_context.h" | 38 #include "webkit/browser/blob/blob_storage_context.h" |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 // BrowserContext creation rather than piggybacking off the default context | 520 // BrowserContext creation rather than piggybacking off the default context |
520 // creation. | 521 // creation. |
521 // Note: moving this into Get() before partitions_[] is set causes reentrency. | 522 // Note: moving this into Get() before partitions_[] is set causes reentrency. |
522 if (!resource_context_initialized_) { | 523 if (!resource_context_initialized_) { |
523 resource_context_initialized_ = true; | 524 resource_context_initialized_ = true; |
524 InitializeResourceContext(browser_context_); | 525 InitializeResourceContext(browser_context_); |
525 } | 526 } |
526 | 527 |
527 // Check first to avoid memory leak in unittests. | 528 // Check first to avoid memory leak in unittests. |
528 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { | 529 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { |
| 530 // Since the appcache can start workers, need to give it a storage |
| 531 // partition those workers should use. |
| 532 WorkerStoragePartition worker_storage_partition( |
| 533 partition->GetURLRequestContext(), |
| 534 partition->GetMediaURLRequestContext(), |
| 535 partition->GetAppCacheService(), |
| 536 partition->GetQuotaManager(), |
| 537 partition->GetFileSystemContext(), |
| 538 partition->GetDatabaseTracker(), |
| 539 partition->GetIndexedDBContext()); |
529 BrowserThread::PostTask( | 540 BrowserThread::PostTask( |
530 BrowserThread::IO, FROM_HERE, | 541 BrowserThread::IO, FROM_HERE, |
531 base::Bind(&ChromeAppCacheService::InitializeOnIOThread, | 542 base::Bind(&ChromeAppCacheService::InitializeOnIOThread, |
532 partition->GetAppCacheService(), | 543 partition->GetAppCacheService(), |
533 in_memory ? base::FilePath() : | 544 in_memory ? base::FilePath() : |
534 partition->GetPath().Append(kAppCacheDirname), | 545 partition->GetPath().Append(kAppCacheDirname), |
535 browser_context_->GetResourceContext(), | 546 browser_context_->GetResourceContext(), |
536 make_scoped_refptr(partition->GetURLRequestContext()), | 547 make_scoped_refptr(partition->GetURLRequestContext()), |
537 make_scoped_refptr( | 548 make_scoped_refptr( |
538 browser_context_->GetSpecialStoragePolicy()))); | 549 browser_context_->GetSpecialStoragePolicy()), |
| 550 worker_storage_partition, |
| 551 make_scoped_refptr( |
| 552 ChromeBlobStorageContext::GetFor(browser_context_)))); |
539 | 553 |
540 // We do not call InitializeURLRequestContext() for media contexts because, | 554 // We do not call InitializeURLRequestContext() for media contexts because, |
541 // other than the HTTP cache, the media contexts share the same backing | 555 // other than the HTTP cache, the media contexts share the same backing |
542 // objects as their associated "normal" request context. Thus, the previous | 556 // objects as their associated "normal" request context. Thus, the previous |
543 // call serves to initialize the media request context for this storage | 557 // call serves to initialize the media request context for this storage |
544 // partition as well. | 558 // partition as well. |
545 } | 559 } |
546 } | 560 } |
547 | 561 |
548 } // namespace content | 562 } // namespace content |
OLD | NEW |