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

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

Issue 10916132: AppCache and StoragePartition'ing (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
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_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/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "content/browser/appcache/chrome_appcache_service.h" 12 #include "content/browser/appcache/chrome_appcache_service.h"
13 #include "content/browser/resource_context_impl.h" 13 #include "content/browser/resource_context_impl.h"
14 #include "content/browser/storage_partition_impl.h" 14 #include "content/browser/storage_partition_impl.h"
15 #include "content/public/browser/browser_context.h" 15 #include "content/public/browser/browser_context.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/common/content_constants.h" 17 #include "content/public/common/content_constants.h"
18 #include "net/url_request/url_request_context_getter.h"
18 19
19 namespace content { 20 namespace content {
20 21
21 StoragePartitionImplMap::StoragePartitionImplMap( 22 StoragePartitionImplMap::StoragePartitionImplMap(
22 BrowserContext* browser_context) 23 BrowserContext* browser_context)
23 : browser_context_(browser_context) { 24 : browser_context_(browser_context) {
24 } 25 }
25 26
26 StoragePartitionImplMap::~StoragePartitionImplMap() { 27 StoragePartitionImplMap::~StoragePartitionImplMap() {
27 STLDeleteContainerPairSecondPointers(partitions_.begin(), 28 STLDeleteContainerPairSecondPointers(partitions_.begin(),
(...skipping 14 matching lines...) Expand all
42 // TODO(ajwong): This should check the path is valid? 43 // TODO(ajwong): This should check the path is valid?
43 CHECK(IsStringASCII(partition_id)); 44 CHECK(IsStringASCII(partition_id));
44 partition_path = partition_path.Append(kStoragePartitionDirname) 45 partition_path = partition_path.Append(kStoragePartitionDirname)
45 .AppendASCII(partition_id); 46 .AppendASCII(partition_id);
46 } 47 }
47 48
48 StoragePartitionImpl* storage_partition = 49 StoragePartitionImpl* storage_partition =
49 StoragePartitionImpl::Create(browser_context_, partition_path); 50 StoragePartitionImpl::Create(browser_context_, partition_path);
50 partitions_[partition_id] = storage_partition; 51 partitions_[partition_id] = storage_partition;
51 52
52 PostCreateInitialization(storage_partition, partition_path); 53 net::URLRequestContextGetter* request_context;
54 if (partition_id.empty()) {
55 request_context = browser_context_->GetRequestContext();
56 } else {
57 // TODO(michaeln/awong): Provide the request context that corresponds to
58 // to this partition. For now, the appcache is initialized into a disabled
59 // state by providing the NULL input. http://crbug.com/85121
michaeln 2012/09/13 00:21:20 NOTE!!!
awong 2012/09/13 00:45:50 Ah hah...yes. This is a problem. A solution would
michaeln 2012/09/13 01:37:20 Should i be worried about "guest-<appid>" being us
60 request_context = NULL;
61 }
62
63 PostCreateInitialization(storage_partition, partition_path, request_context);
53 64
54 // TODO(ajwong): We need to remove this conditional by making 65 // TODO(ajwong): We need to remove this conditional by making
55 // InitializeResourceContext() understand having different partition data 66 // InitializeResourceContext() understand having different partition data
56 // based on the renderer_id. 67 // based on the renderer_id.
57 if (partition_id.empty()) { 68 if (partition_id.empty()) {
58 InitializeResourceContext(browser_context_); 69 InitializeResourceContext(browser_context_);
59 } 70 }
60 71
61 return storage_partition; 72 return storage_partition;
62 } 73 }
63 74
64 void StoragePartitionImplMap::ForEach( 75 void StoragePartitionImplMap::ForEach(
65 const BrowserContext::StoragePartitionCallback& callback) { 76 const BrowserContext::StoragePartitionCallback& callback) {
66 for (std::map<std::string, StoragePartitionImpl*>::const_iterator it = 77 for (std::map<std::string, StoragePartitionImpl*>::const_iterator it =
67 partitions_.begin(); 78 partitions_.begin();
68 it != partitions_.end(); 79 it != partitions_.end();
69 ++it) { 80 ++it) {
70 callback.Run(it->first, it->second); 81 callback.Run(it->first, it->second);
71 } 82 }
72 } 83 }
73 84
74 void StoragePartitionImplMap::PostCreateInitialization( 85 void StoragePartitionImplMap::PostCreateInitialization(
75 StoragePartitionImpl* partition, 86 StoragePartitionImpl* partition,
76 const FilePath& partition_path) { 87 const FilePath& partition_path,
88 net::URLRequestContextGetter* request_context_getter) {
77 // Check first to avoid memory leak in unittests. 89 // Check first to avoid memory leak in unittests.
78 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { 90 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) {
79 BrowserThread::PostTask( 91 BrowserThread::PostTask(
80 BrowserThread::IO, FROM_HERE, 92 BrowserThread::IO, FROM_HERE,
81 base::Bind(&ChromeAppCacheService::InitializeOnIOThread, 93 base::Bind(&ChromeAppCacheService::InitializeOnIOThread,
82 partition->GetAppCacheService(), 94 partition->GetAppCacheService(),
83 browser_context_->IsOffTheRecord() ? FilePath() : 95 browser_context_->IsOffTheRecord() ? FilePath() :
84 partition_path.Append(kAppCacheDirname), 96 partition_path.Append(kAppCacheDirname),
85 // TODO(michaeln): This is not right, appcache will be 97 browser_context_->GetResourceContext(),
86 // using the cookies and cache of a the default 98 make_scoped_refptr(request_context_getter),
87 // partition when populating the cache.
88 // http://crbug.com/85121
89 browser_context_->GetResourceContext(),
90 make_scoped_refptr( 99 make_scoped_refptr(
91 browser_context_->GetSpecialStoragePolicy()))); 100 browser_context_->GetSpecialStoragePolicy())));
92 } 101 }
93 } 102 }
94 103
95 } // namespace content 104 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698