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

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

Issue 12386009: Remove the chrome:// protocol interceptor since it's not used anymore now that the chrome job facto… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 9 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
« no previous file with comments | « chrome/test/base/testing_profile.cc ('k') | content/browser/webui/url_data_manager_backend.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/stringprintf.h" 14 #include "base/stringprintf.h"
15 #include "base/threading/sequenced_worker_pool.h" 15 #include "base/threading/sequenced_worker_pool.h"
16 #include "content/browser/appcache/chrome_appcache_service.h" 16 #include "content/browser/appcache/chrome_appcache_service.h"
17 #include "content/browser/fileapi/browser_file_system_helper.h" 17 #include "content/browser/fileapi/browser_file_system_helper.h"
18 #include "content/browser/fileapi/chrome_blob_storage_context.h" 18 #include "content/browser/fileapi/chrome_blob_storage_context.h"
19 #include "content/browser/histogram_internals_request_job.h"
20 #include "content/browser/loader/resource_request_info_impl.h" 19 #include "content/browser/loader/resource_request_info_impl.h"
21 #include "content/browser/net/view_blob_internals_job_factory.h"
22 #include "content/browser/net/view_http_cache_job_factory.h"
23 #include "content/browser/resource_context_impl.h" 20 #include "content/browser/resource_context_impl.h"
24 #include "content/browser/storage_partition_impl.h" 21 #include "content/browser/storage_partition_impl.h"
25 #include "content/browser/tcmalloc_internals_request_job.h"
26 #include "content/browser/webui/url_data_manager_backend.h" 22 #include "content/browser/webui/url_data_manager_backend.h"
27 #include "content/public/browser/browser_context.h" 23 #include "content/public/browser/browser_context.h"
28 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/content_browser_client.h" 25 #include "content/public/browser/content_browser_client.h"
30 #include "content/public/browser/storage_partition.h" 26 #include "content/public/browser/storage_partition.h"
31 #include "content/public/common/content_constants.h" 27 #include "content/public/common/content_constants.h"
32 #include "content/public/common/url_constants.h" 28 #include "content/public/common/url_constants.h"
33 #include "crypto/sha2.h" 29 #include "crypto/sha2.h"
34 #include "net/url_request/url_request_context.h" 30 #include "net/url_request/url_request_context.h"
35 #include "net/url_request/url_request_context_getter.h" 31 #include "net/url_request/url_request_context_getter.h"
36 #include "webkit/appcache/view_appcache_internals_job.h"
37 #include "webkit/blob/blob_data.h" 32 #include "webkit/blob/blob_data.h"
38 #include "webkit/blob/blob_url_request_job_factory.h" 33 #include "webkit/blob/blob_url_request_job_factory.h"
39 #include "webkit/fileapi/file_system_url_request_job_factory.h" 34 #include "webkit/fileapi/file_system_url_request_job_factory.h"
40 35
41 using appcache::AppCacheService; 36 using appcache::AppCacheService;
42 using fileapi::FileSystemContext; 37 using fileapi::FileSystemContext;
43 using webkit_blob::BlobStorageController; 38 using webkit_blob::BlobStorageController;
44 39
45 namespace content { 40 namespace content {
46 41
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 95
101 const scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; 96 const scoped_refptr<ChromeBlobStorageContext> blob_storage_context_;
102 const scoped_refptr<fileapi::FileSystemContext> file_system_context_; 97 const scoped_refptr<fileapi::FileSystemContext> file_system_context_;
103 98
104 mutable scoped_ptr<WebKitBlobProtocolHandlerImpl> 99 mutable scoped_ptr<WebKitBlobProtocolHandlerImpl>
105 webkit_blob_protocol_handler_impl_; 100 webkit_blob_protocol_handler_impl_;
106 101
107 DISALLOW_COPY_AND_ASSIGN(BlobProtocolHandler); 102 DISALLOW_COPY_AND_ASSIGN(BlobProtocolHandler);
108 }; 103 };
109 104
110 // 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
112 // with it, and no need to expose the content/chrome separation through our UI).
113 class DeveloperProtocolHandler
114 : public net::URLRequestJobFactory::ProtocolHandler {
115 public:
116 DeveloperProtocolHandler(
117 AppCacheService* appcache_service,
118 ChromeBlobStorageContext* blob_storage_context)
119 : appcache_service_(appcache_service),
120 blob_storage_context_(blob_storage_context) {}
121 virtual ~DeveloperProtocolHandler() {}
122
123 virtual net::URLRequestJob* MaybeCreateJob(
124 net::URLRequest* request,
125 net::NetworkDelegate* network_delegate) const OVERRIDE {
126 // Check for chrome://view-http-cache/*, which uses its own job type.
127 if (ViewHttpCacheJobFactory::IsSupportedURL(request->url()))
128 return ViewHttpCacheJobFactory::CreateJobForRequest(request,
129 network_delegate);
130
131 // Next check for chrome://appcache-internals/, which uses its own job type.
132 if (request->url().SchemeIs(chrome::kChromeUIScheme) &&
133 request->url().host() == chrome::kChromeUIAppCacheInternalsHost) {
134 return appcache::ViewAppCacheInternalsJobFactory::CreateJobForRequest(
135 request, network_delegate, appcache_service_);
136 }
137
138 // Next check for chrome://blob-internals/, which uses its own job type.
139 if (ViewBlobInternalsJobFactory::IsSupportedURL(request->url())) {
140 return ViewBlobInternalsJobFactory::CreateJobForRequest(
141 request, network_delegate, blob_storage_context_->controller());
142 }
143
144 #if defined(USE_TCMALLOC)
145 // Next check for chrome://tcmalloc/, which uses its own job type.
146 if (request->url().SchemeIs(chrome::kChromeUIScheme) &&
147 request->url().host() == chrome::kChromeUITcmallocHost) {
148 return new TcmallocInternalsRequestJob(request, network_delegate);
149 }
150 #endif
151
152 // Next check for chrome://histograms/, which uses its own job type.
153 if (request->url().SchemeIs(chrome::kChromeUIScheme) &&
154 request->url().host() == chrome::kChromeUIHistogramHost) {
155 return new HistogramInternalsRequestJob(request, network_delegate);
156 }
157
158 return NULL;
159 }
160
161 private:
162 AppCacheService* appcache_service_;
163 ChromeBlobStorageContext* blob_storage_context_;
164 };
165
166 // These constants are used to create the directory structure under the profile 105 // These constants are used to create the directory structure under the profile
167 // where renderers with a non-default storage partition keep their persistent 106 // where renderers with a non-default storage partition keep their persistent
168 // state. This will contain a set of directories that partially mirror the 107 // state. This will contain a set of directories that partially mirror the
169 // directory structure of BrowserContext::GetPath(). 108 // directory structure of BrowserContext::GetPath().
170 // 109 //
171 // The kStoragePartitionDirname contains an extensions directory which is 110 // The kStoragePartitionDirname contains an extensions directory which is
172 // further partitioned by extension id, followed by another level of directories 111 // further partitioned by extension id, followed by another level of directories
173 // for the "default" extension storage partition and one directory for each 112 // for the "default" extension storage partition and one directory for each
174 // persistent partition used by a webview tag. Example: 113 // persistent partition used by a webview tag. Example:
175 // 114 //
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 386
448 ChromeBlobStorageContext* blob_storage_context = 387 ChromeBlobStorageContext* blob_storage_context =
449 ChromeBlobStorageContext::GetFor(browser_context_); 388 ChromeBlobStorageContext::GetFor(browser_context_);
450 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> blob_protocol_handler( 389 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> blob_protocol_handler(
451 new BlobProtocolHandler(blob_storage_context, 390 new BlobProtocolHandler(blob_storage_context,
452 partition->GetFileSystemContext())); 391 partition->GetFileSystemContext()));
453 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 392 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
454 file_system_protocol_handler( 393 file_system_protocol_handler(
455 CreateFileSystemProtocolHandler(partition->GetFileSystemContext())); 394 CreateFileSystemProtocolHandler(partition->GetFileSystemContext()));
456 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 395 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
457 developer_protocol_handler(
458 new DeveloperProtocolHandler(partition->GetAppCacheService(),
459 blob_storage_context));
460 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
461 chrome_protocol_handler( 396 chrome_protocol_handler(
462 URLDataManagerBackend::CreateProtocolHandler( 397 URLDataManagerBackend::CreateProtocolHandler(
463 browser_context_->GetResourceContext(), 398 browser_context_->GetResourceContext(),
464 browser_context_->IsOffTheRecord())); 399 browser_context_->IsOffTheRecord(),
400 partition->GetAppCacheService(),
401 blob_storage_context));
465 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler> 402 scoped_ptr<net::URLRequestJobFactory::ProtocolHandler>
466 chrome_devtools_protocol_handler( 403 chrome_devtools_protocol_handler(
467 CreateDevToolsProtocolHandler(browser_context_->GetResourceContext(), 404 CreateDevToolsProtocolHandler(browser_context_->GetResourceContext(),
468 browser_context_->IsOffTheRecord())); 405 browser_context_->IsOffTheRecord()));
469 406
470 // These calls must happen after StoragePartitionImpl::Create(). 407 // These calls must happen after StoragePartitionImpl::Create().
471 if (partition_domain.empty()) { 408 if (partition_domain.empty()) {
472 partition->SetURLRequestContext( 409 partition->SetURLRequestContext(
473 GetContentClient()->browser()->CreateRequestContext(browser_context_, 410 GetContentClient()->browser()->CreateRequestContext(browser_context_,
474 blob_protocol_handler.Pass(), file_system_protocol_handler.Pass(), 411 blob_protocol_handler.Pass(), file_system_protocol_handler.Pass(),
475 developer_protocol_handler.Pass(), chrome_protocol_handler.Pass(), 412 chrome_protocol_handler.Pass(),
476 chrome_devtools_protocol_handler.Pass())); 413 chrome_devtools_protocol_handler.Pass()));
477 } else { 414 } else {
478 partition->SetURLRequestContext( 415 partition->SetURLRequestContext(
479 GetContentClient()->browser()->CreateRequestContextForStoragePartition( 416 GetContentClient()->browser()->CreateRequestContextForStoragePartition(
480 browser_context_, partition->GetPath(), in_memory, 417 browser_context_, partition->GetPath(), in_memory,
481 blob_protocol_handler.Pass(), file_system_protocol_handler.Pass(), 418 blob_protocol_handler.Pass(), file_system_protocol_handler.Pass(),
482 developer_protocol_handler.Pass(), chrome_protocol_handler.Pass(), 419 chrome_protocol_handler.Pass(),
483 chrome_devtools_protocol_handler.Pass())); 420 chrome_devtools_protocol_handler.Pass()));
484 } 421 }
485 partition->SetMediaURLRequestContext( 422 partition->SetMediaURLRequestContext(
486 partition_domain.empty() ? 423 partition_domain.empty() ?
487 browser_context_->GetMediaRequestContext() : 424 browser_context_->GetMediaRequestContext() :
488 browser_context_->GetMediaRequestContextForStoragePartition( 425 browser_context_->GetMediaRequestContextForStoragePartition(
489 partition->GetPath(), in_memory)); 426 partition->GetPath(), in_memory));
490 427
491 PostCreateInitialization(partition, in_memory); 428 PostCreateInitialization(partition, in_memory);
492 429
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 539
603 // We do not call InitializeURLRequestContext() for media contexts because, 540 // We do not call InitializeURLRequestContext() for media contexts because,
604 // other than the HTTP cache, the media contexts share the same backing 541 // other than the HTTP cache, the media contexts share the same backing
605 // objects as their associated "normal" request context. Thus, the previous 542 // objects as their associated "normal" request context. Thus, the previous
606 // call serves to initialize the media request context for this storage 543 // call serves to initialize the media request context for this storage
607 // partition as well. 544 // partition as well.
608 } 545 }
609 } 546 }
610 547
611 } // namespace content 548 } // namespace content
OLDNEW
« no previous file with comments | « chrome/test/base/testing_profile.cc ('k') | content/browser/webui/url_data_manager_backend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698