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

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

Issue 11410019: ********** Chromium Blob hacking (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 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 | 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/file_util.h" 10 #include "base/file_util.h"
(...skipping 17 matching lines...) Expand all
28 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/content_browser_client.h" 29 #include "content/public/browser/content_browser_client.h"
30 #include "content/public/browser/storage_partition.h" 30 #include "content/public/browser/storage_partition.h"
31 #include "content/public/common/content_constants.h" 31 #include "content/public/common/content_constants.h"
32 #include "content/public/common/url_constants.h" 32 #include "content/public/common/url_constants.h"
33 #include "crypto/sha2.h" 33 #include "crypto/sha2.h"
34 #include "net/url_request/url_request_context_getter.h" 34 #include "net/url_request/url_request_context_getter.h"
35 #include "net/url_request/url_request_context.h" 35 #include "net/url_request/url_request_context.h"
36 #include "webkit/appcache/view_appcache_internals_job.h" 36 #include "webkit/appcache/view_appcache_internals_job.h"
37 #include "webkit/blob/blob_data.h" 37 #include "webkit/blob/blob_data.h"
38 #include "webkit/blob/blob_storage_context.h"
38 #include "webkit/blob/blob_url_request_job_factory.h" 39 #include "webkit/blob/blob_url_request_job_factory.h"
39 #include "webkit/fileapi/file_system_url_request_job_factory.h" 40 #include "webkit/fileapi/file_system_url_request_job_factory.h"
40 41
41 using appcache::AppCacheService; 42 using appcache::AppCacheService;
42 using fileapi::FileSystemContext; 43 using fileapi::FileSystemContext;
43 using webkit_blob::BlobStorageController; 44 using webkit_blob::BlobStorageContext;
44 45
45 namespace content { 46 namespace content {
46 47
47 namespace { 48 namespace {
48 49
49 class BlobProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler {
50 public:
51 BlobProtocolHandler(ChromeBlobStorageContext* blob_storage_context,
52 fileapi::FileSystemContext* file_system_context)
53 : blob_storage_context_(blob_storage_context),
54 file_system_context_(file_system_context) {}
55
56 virtual ~BlobProtocolHandler() {}
57
58 virtual net::URLRequestJob* MaybeCreateJob(
59 net::URLRequest* request,
60 net::NetworkDelegate* network_delegate) const OVERRIDE {
61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
62 if (!webkit_blob_protocol_handler_impl_) {
63 webkit_blob_protocol_handler_impl_.reset(
64 new WebKitBlobProtocolHandlerImpl(blob_storage_context_->controller(),
65 file_system_context_));
66 }
67 return webkit_blob_protocol_handler_impl_->MaybeCreateJob(request,
68 network_delegate);
69 }
70
71 private:
72 // An implementation of webkit_blob::BlobProtocolHandler that gets
73 // the BlobData from ResourceRequestInfoImpl.
74 class WebKitBlobProtocolHandlerImpl
75 : public webkit_blob::BlobProtocolHandler {
76 public:
77 WebKitBlobProtocolHandlerImpl(
78 webkit_blob::BlobStorageController* blob_storage_controller,
79 fileapi::FileSystemContext* file_system_context)
80 : webkit_blob::BlobProtocolHandler(
81 blob_storage_controller, file_system_context,
82 BrowserThread::GetMessageLoopProxyForThread(
83 BrowserThread::FILE)) {}
84
85 virtual ~WebKitBlobProtocolHandlerImpl() {}
86
87 private:
88 // webkit_blob::BlobProtocolHandler implementation.
89 virtual scoped_refptr<webkit_blob::BlobData>
90 LookupBlobData(net::URLRequest* request) const OVERRIDE {
91 const ResourceRequestInfoImpl* info =
92 ResourceRequestInfoImpl::ForRequest(request);
93 if (!info)
94 return NULL;
95 return info->requested_blob_data();
96 }
97
98 DISALLOW_COPY_AND_ASSIGN(WebKitBlobProtocolHandlerImpl);
99 };
100
101 const scoped_refptr<ChromeBlobStorageContext> blob_storage_context_;
102 const scoped_refptr<fileapi::FileSystemContext> file_system_context_;
103
104 mutable scoped_ptr<WebKitBlobProtocolHandlerImpl>
105 webkit_blob_protocol_handler_impl_;
106
107 DISALLOW_COPY_AND_ASSIGN(BlobProtocolHandler);
108 };
109
110 // Adds a bunch of debugging urls. We use an interceptor instead of a protocol 50 // Adds a bunch of debugging urls. We use an interceptor instead of a protocol
111 // handler because we want to reuse the chrome://scheme (everyone is familiar 51 // handler because we want to reuse the chrome://scheme (everyone is familiar
112 // with it, and no need to expose the content/chrome separation through our UI). 52 // with it, and no need to expose the content/chrome separation through our UI).
113 class DeveloperProtocolHandler 53 class DeveloperProtocolHandler
114 : public net::URLRequestJobFactory::ProtocolHandler { 54 : public net::URLRequestJobFactory::ProtocolHandler {
115 public: 55 public:
116 DeveloperProtocolHandler( 56 DeveloperProtocolHandler(
117 AppCacheService* appcache_service, 57 AppCacheService* appcache_service,
118 ChromeBlobStorageContext* blob_storage_context) 58 BlobStorageContext* blob_storage_context)
119 : appcache_service_(appcache_service), 59 : appcache_service_(appcache_service),
120 blob_storage_context_(blob_storage_context) {} 60 blob_storage_context_(blob_storage_context) {}
121 virtual ~DeveloperProtocolHandler() {} 61 virtual ~DeveloperProtocolHandler() {}
122 62
123 virtual net::URLRequestJob* MaybeCreateJob( 63 virtual net::URLRequestJob* MaybeCreateJob(
124 net::URLRequest* request, 64 net::URLRequest* request,
125 net::NetworkDelegate* network_delegate) const OVERRIDE { 65 net::NetworkDelegate* network_delegate) const OVERRIDE {
126 // Check for chrome://view-http-cache/*, which uses its own job type. 66 // Check for chrome://view-http-cache/*, which uses its own job type.
127 if (ViewHttpCacheJobFactory::IsSupportedURL(request->url())) 67 if (ViewHttpCacheJobFactory::IsSupportedURL(request->url()))
128 return ViewHttpCacheJobFactory::CreateJobForRequest(request, 68 return ViewHttpCacheJobFactory::CreateJobForRequest(request,
129 network_delegate); 69 network_delegate);
130 70
131 // Next check for chrome://appcache-internals/, which uses its own job type. 71 // Next check for chrome://appcache-internals/, which uses its own job type.
132 if (request->url().SchemeIs(chrome::kChromeUIScheme) && 72 if (request->url().SchemeIs(chrome::kChromeUIScheme) &&
133 request->url().host() == chrome::kChromeUIAppCacheInternalsHost) { 73 request->url().host() == chrome::kChromeUIAppCacheInternalsHost) {
134 return appcache::ViewAppCacheInternalsJobFactory::CreateJobForRequest( 74 return appcache::ViewAppCacheInternalsJobFactory::CreateJobForRequest(
135 request, network_delegate, appcache_service_); 75 request, network_delegate, appcache_service_);
136 } 76 }
137 77
138 // Next check for chrome://blob-internals/, which uses its own job type. 78 //// Next check for chrome://blob-internals/, which uses its own job type.
139 if (ViewBlobInternalsJobFactory::IsSupportedURL(request->url())) { 79 //if (ViewBlobInternalsJobFactory::IsSupportedURL(request->url())) {
140 return ViewBlobInternalsJobFactory::CreateJobForRequest( 80 // return ViewBlobInternalsJobFactory::CreateJobForRequest(
141 request, network_delegate, blob_storage_context_->controller()); 81 // request, network_delegate, blob_storage_controller_);
142 } 82 //}
143 83
144 #if defined(USE_TCMALLOC) 84 #if defined(USE_TCMALLOC)
145 // Next check for chrome://tcmalloc/, which uses its own job type. 85 // Next check for chrome://tcmalloc/, which uses its own job type.
146 if (request->url().SchemeIs(chrome::kChromeUIScheme) && 86 if (request->url().SchemeIs(chrome::kChromeUIScheme) &&
147 request->url().host() == chrome::kChromeUITcmallocHost) { 87 request->url().host() == chrome::kChromeUITcmallocHost) {
148 return new TcmallocInternalsRequestJob(request, network_delegate); 88 return new TcmallocInternalsRequestJob(request, network_delegate);
149 } 89 }
150 #endif 90 #endif
151 91
152 // Next check for chrome://histograms/, which uses its own job type. 92 // Next check for chrome://histograms/, which uses its own job type.
153 if (request->url().SchemeIs(chrome::kChromeUIScheme) && 93 if (request->url().SchemeIs(chrome::kChromeUIScheme) &&
154 request->url().host() == chrome::kChromeUIHistogramHost) { 94 request->url().host() == chrome::kChromeUIHistogramHost) {
155 return new HistogramInternalsRequestJob(request, network_delegate); 95 return new HistogramInternalsRequestJob(request, network_delegate);
156 } 96 }
157 97
158 return NULL; 98 return NULL;
159 } 99 }
160 100
161 private: 101 private:
162 AppCacheService* appcache_service_; 102 AppCacheService* appcache_service_;
163 ChromeBlobStorageContext* blob_storage_context_; 103 BlobStorageContext* blob_storage_context_;
164 }; 104 };
165 105
166 // These constants are used to create the directory structure under the profile 106 // These constants are used to create the directory structure under the profile
167 // where renderers with a non-default storage partition keep their persistent 107 // where renderers with a non-default storage partition keep their persistent
168 // state. This will contain a set of directories that partially mirror the 108 // state. This will contain a set of directories that partially mirror the
169 // directory structure of BrowserContext::GetPath(). 109 // directory structure of BrowserContext::GetPath().
170 // 110 //
171 // The kStoragePartitionDirname contains an extensions directory which is 111 // The kStoragePartitionDirname contains an extensions directory which is
172 // further partitioned by extension id, followed by another level of directories 112 // further partitioned by extension id, followed by another level of directories
173 // for the "default" extension storage partition and one directory for each 113 // for the "default" extension storage partition and one directory for each
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 browser_context_->GetPath().Append( 381 browser_context_->GetPath().Append(
442 GetStoragePartitionPath(partition_domain, partition_name)); 382 GetStoragePartitionPath(partition_domain, partition_name));
443 StoragePartitionImpl* partition = 383 StoragePartitionImpl* partition =
444 StoragePartitionImpl::Create(browser_context_, in_memory, 384 StoragePartitionImpl::Create(browser_context_, in_memory,
445 partition_path); 385 partition_path);
446 partitions_[partition_config] = partition; 386 partitions_[partition_config] = partition;
447 387
448 ChromeBlobStorageContext* blob_storage_context = 388 ChromeBlobStorageContext* blob_storage_context =
449 ChromeBlobStorageContext::GetFor(browser_context_); 389 ChromeBlobStorageContext::GetFor(browser_context_);
450 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> blob_protocol_handler( 390 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> blob_protocol_handler(
451 new BlobProtocolHandler(blob_storage_context, 391 new webkit_blob::BlobProtocolHandler(
452 partition->GetFileSystemContext())); 392 blob_storage_context->context(),
393 partition->GetFileSystemContext(),
394 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)));
453 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 395 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
454 file_system_protocol_handler( 396 file_system_protocol_handler(
455 CreateFileSystemProtocolHandler(partition->GetFileSystemContext())); 397 CreateFileSystemProtocolHandler(partition->GetFileSystemContext()));
456 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 398 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
457 developer_protocol_handler( 399 developer_protocol_handler(
458 new DeveloperProtocolHandler(partition->GetAppCacheService(), 400 new DeveloperProtocolHandler(partition->GetAppCacheService(),
459 blob_storage_context)); 401 blob_storage_context->context()));
460 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 402 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
461 chrome_protocol_handler( 403 chrome_protocol_handler(
462 URLDataManagerBackend::CreateProtocolHandler( 404 URLDataManagerBackend::CreateProtocolHandler(
463 browser_context_->GetResourceContext(), 405 browser_context_->GetResourceContext(),
464 browser_context_->IsOffTheRecord())); 406 browser_context_->IsOffTheRecord()));
465 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 407 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
466 chrome_devtools_protocol_handler( 408 chrome_devtools_protocol_handler(
467 CreateDevToolsProtocolHandler(browser_context_->GetResourceContext(), 409 CreateDevToolsProtocolHandler(browser_context_->GetResourceContext(),
468 browser_context_->IsOffTheRecord())); 410 browser_context_->IsOffTheRecord()));
469 411
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 544
603 // We do not call InitializeURLRequestContext() for media contexts because, 545 // We do not call InitializeURLRequestContext() for media contexts because,
604 // other than the HTTP cache, the media contexts share the same backing 546 // other than the HTTP cache, the media contexts share the same backing
605 // objects as their associated "normal" request context. Thus, the previous 547 // objects as their associated "normal" request context. Thus, the previous
606 // call serves to initialize the media request context for this storage 548 // call serves to initialize the media request context for this storage
607 // partition as well. 549 // partition as well.
608 } 550 }
609 } 551 }
610 552
611 } // namespace content 553 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/net/view_blob_internals_job_factory.cc ('k') | content/common/fileapi/file_system_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698