| 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_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 | 447 |
| 448 StoragePartitionImplMap::~StoragePartitionImplMap() { | 448 StoragePartitionImplMap::~StoragePartitionImplMap() { |
| 449 STLDeleteContainerPairSecondPointers(partitions_.begin(), | 449 STLDeleteContainerPairSecondPointers(partitions_.begin(), |
| 450 partitions_.end()); | 450 partitions_.end()); |
| 451 } | 451 } |
| 452 | 452 |
| 453 StoragePartitionImpl* StoragePartitionImplMap::Get( | 453 StoragePartitionImpl* StoragePartitionImplMap::Get( |
| 454 const std::string& partition_domain, | 454 const std::string& partition_domain, |
| 455 const std::string& partition_name, | 455 const std::string& partition_name, |
| 456 bool in_memory) { | 456 bool in_memory) { |
| 457 // TODO(ajwong): ResourceContexts no longer have any storage related state. | |
| 458 // We should move this into a place where it is called once per | |
| 459 // BrowserContext creation rather than piggybacking off the default context | |
| 460 // creation. | |
| 461 if (!resource_context_initialized_) { | |
| 462 resource_context_initialized_ = true; | |
| 463 InitializeResourceContext(browser_context_); | |
| 464 } | |
| 465 | |
| 466 // Find the previously created partition if it's available. | 457 // Find the previously created partition if it's available. |
| 467 StoragePartitionConfig partition_config( | 458 StoragePartitionConfig partition_config( |
| 468 partition_domain, partition_name, in_memory); | 459 partition_domain, partition_name, in_memory); |
| 469 | 460 |
| 470 PartitionMap::const_iterator it = partitions_.find(partition_config); | 461 PartitionMap::const_iterator it = partitions_.find(partition_config); |
| 471 if (it != partitions_.end()) | 462 if (it != partitions_.end()) |
| 472 return it->second; | 463 return it->second; |
| 473 | 464 |
| 474 FilePath partition_path = | 465 FilePath partition_path = |
| 475 browser_context_->GetPath().Append( | 466 browser_context_->GetPath().Append( |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 for (PartitionMap::const_iterator it = partitions_.begin(); | 564 for (PartitionMap::const_iterator it = partitions_.begin(); |
| 574 it != partitions_.end(); | 565 it != partitions_.end(); |
| 575 ++it) { | 566 ++it) { |
| 576 callback.Run(it->second); | 567 callback.Run(it->second); |
| 577 } | 568 } |
| 578 } | 569 } |
| 579 | 570 |
| 580 void StoragePartitionImplMap::PostCreateInitialization( | 571 void StoragePartitionImplMap::PostCreateInitialization( |
| 581 StoragePartitionImpl* partition, | 572 StoragePartitionImpl* partition, |
| 582 bool in_memory) { | 573 bool in_memory) { |
| 574 // TODO(ajwong): ResourceContexts no longer have any storage related state. |
| 575 // We should move this into a place where it is called once per |
| 576 // BrowserContext creation rather than piggybacking off the default context |
| 577 // creation. |
| 578 if (!resource_context_initialized_) { |
| 579 resource_context_initialized_ = true; |
| 580 InitializeResourceContext(browser_context_); |
| 581 } |
| 582 |
| 583 // Check first to avoid memory leak in unittests. | 583 // Check first to avoid memory leak in unittests. |
| 584 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { | 584 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { |
| 585 BrowserThread::PostTask( | 585 BrowserThread::PostTask( |
| 586 BrowserThread::IO, FROM_HERE, | 586 BrowserThread::IO, FROM_HERE, |
| 587 base::Bind(&ChromeAppCacheService::InitializeOnIOThread, | 587 base::Bind(&ChromeAppCacheService::InitializeOnIOThread, |
| 588 partition->GetAppCacheService(), | 588 partition->GetAppCacheService(), |
| 589 in_memory ? FilePath() : | 589 in_memory ? FilePath() : |
| 590 partition->GetPath().Append(kAppCacheDirname), | 590 partition->GetPath().Append(kAppCacheDirname), |
| 591 browser_context_->GetResourceContext(), | 591 browser_context_->GetResourceContext(), |
| 592 make_scoped_refptr(partition->GetURLRequestContext()), | 592 make_scoped_refptr(partition->GetURLRequestContext()), |
| (...skipping 13 matching lines...) Expand all Loading... |
| 606 | 606 |
| 607 // We do not call InitializeURLRequestContext() for media contexts because, | 607 // We do not call InitializeURLRequestContext() for media contexts because, |
| 608 // other than the HTTP cache, the media contexts share the same backing | 608 // other than the HTTP cache, the media contexts share the same backing |
| 609 // objects as their associated "normal" request context. Thus, the previous | 609 // objects as their associated "normal" request context. Thus, the previous |
| 610 // call serves to initialize the media request context for this storage | 610 // call serves to initialize the media request context for this storage |
| 611 // partition as well. | 611 // partition as well. |
| 612 } | 612 } |
| 613 } | 613 } |
| 614 | 614 |
| 615 } // namespace content | 615 } // namespace content |
| OLD | NEW |