| 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" |
| 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" | 19 #include "content/browser/histogram_internals_request_job.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/net/view_blob_internals_job_factory.h" | 21 #include "content/browser/net/view_blob_internals_job_factory.h" |
| 22 #include "content/browser/net/view_http_cache_job_factory.h" | 22 #include "content/browser/net/view_http_cache_job_factory.h" |
| 23 #include "content/browser/resource_context_impl.h" | 23 #include "content/browser/resource_context_impl.h" |
| 24 #include "content/browser/storage_partition_impl.h" | 24 #include "content/browser/storage_partition_impl.h" |
| 25 #include "content/browser/webui/url_data_manager_backend.h" |
| 25 #include "content/browser/tcmalloc_internals_request_job.h" | 26 #include "content/browser/tcmalloc_internals_request_job.h" |
| 26 #include "content/public/browser/browser_context.h" | 27 #include "content/public/browser/browser_context.h" |
| 27 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| 28 #include "content/public/browser/content_browser_client.h" | 29 #include "content/public/browser/content_browser_client.h" |
| 29 #include "content/public/browser/storage_partition.h" | 30 #include "content/public/browser/storage_partition.h" |
| 30 #include "content/public/common/content_constants.h" | 31 #include "content/public/common/content_constants.h" |
| 31 #include "content/public/common/url_constants.h" | 32 #include "content/public/common/url_constants.h" |
| 32 #include "crypto/sha2.h" | 33 #include "crypto/sha2.h" |
| 33 #include "net/url_request/url_request_context_getter.h" | 34 #include "net/url_request/url_request_context_getter.h" |
| 34 #include "net/url_request/url_request_context.h" | 35 #include "net/url_request/url_request_context.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 141 |
| 141 private: | 142 private: |
| 142 AppCacheService* appcache_service_; | 143 AppCacheService* appcache_service_; |
| 143 BlobStorageController* blob_storage_controller_; | 144 BlobStorageController* blob_storage_controller_; |
| 144 }; | 145 }; |
| 145 | 146 |
| 146 void InitializeURLRequestContext( | 147 void InitializeURLRequestContext( |
| 147 net::URLRequestContextGetter* context_getter, | 148 net::URLRequestContextGetter* context_getter, |
| 148 AppCacheService* appcache_service, | 149 AppCacheService* appcache_service, |
| 149 FileSystemContext* file_system_context, | 150 FileSystemContext* file_system_context, |
| 150 ChromeBlobStorageContext* blob_storage_context) { | 151 ChromeBlobStorageContext* blob_storage_context, |
| 152 ResourceContext* resource_context, |
| 153 bool off_the_record) { |
| 151 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 154 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 152 if (!context_getter) | 155 if (!context_getter) |
| 153 return; // tests. | 156 return; // tests. |
| 154 | 157 |
| 155 // This code only modifies the URLRequestJobFactory on the context | 158 // This code only modifies the URLRequestJobFactory on the context |
| 156 // to handle blob: URLs, filesystem: URLs, and to let AppCache intercept | 159 // to handle blob: URLs, filesystem: URLs, and to let AppCache intercept |
| 157 // the appropriate requests. This is in addition to the slew of other | 160 // the appropriate requests. This is in addition to the slew of other |
| 158 // initializtion that is done in during creation of the URLRequestContext. | 161 // initializtion that is done in during creation of the URLRequestContext. |
| 159 // We cannot yet centralize this code because URLRequestContext needs | 162 // We cannot yet centralize this code because URLRequestContext needs |
| 160 // to be created before the StoragePartition context. | 163 // to be created before the StoragePartition context. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 179 DCHECK(set_protocol); | 182 DCHECK(set_protocol); |
| 180 set_protocol = job_factory->SetProtocolHandler( | 183 set_protocol = job_factory->SetProtocolHandler( |
| 181 chrome::kFileSystemScheme, | 184 chrome::kFileSystemScheme, |
| 182 CreateFileSystemProtocolHandler(file_system_context)); | 185 CreateFileSystemProtocolHandler(file_system_context)); |
| 183 DCHECK(set_protocol); | 186 DCHECK(set_protocol); |
| 184 | 187 |
| 185 job_factory->AddInterceptor( | 188 job_factory->AddInterceptor( |
| 186 new DeveloperProtocolHandler(appcache_service, | 189 new DeveloperProtocolHandler(appcache_service, |
| 187 blob_storage_context->controller())); | 190 blob_storage_context->controller())); |
| 188 | 191 |
| 192 job_factory->SetProtocolHandler( |
| 193 chrome::kChromeUIScheme, |
| 194 ChromeURLDataManagerBackend::CreateProtocolHandler( |
| 195 GetURLDataManagerForResourceContext(resource_context), |
| 196 off_the_record)); |
| 197 |
| 198 job_factory->SetProtocolHandler( |
| 199 chrome::kChromeDevToolsScheme, |
| 200 CreateDevToolsProtocolHandler( |
| 201 GetURLDataManagerForResourceContext(resource_context), |
| 202 off_the_record)); |
| 203 DCHECK(set_protocol); |
| 204 |
| 189 // TODO(jam): Add the ProtocolHandlerRegistryIntercepter here! | 205 // TODO(jam): Add the ProtocolHandlerRegistryIntercepter here! |
| 190 } | 206 } |
| 191 | 207 |
| 192 // These constants are used to create the directory structure under the profile | 208 // These constants are used to create the directory structure under the profile |
| 193 // where renderers with a non-default storage partition keep their persistent | 209 // where renderers with a non-default storage partition keep their persistent |
| 194 // state. This will contain a set of directories that partially mirror the | 210 // state. This will contain a set of directories that partially mirror the |
| 195 // directory structure of BrowserContext::GetPath(). | 211 // directory structure of BrowserContext::GetPath(). |
| 196 // | 212 // |
| 197 // The kStoragePartitionDirname contains an extensions directory which is | 213 // The kStoragePartitionDirname contains an extensions directory which is |
| 198 // further partitioned by extension id, followed by another level of directories | 214 // further partitioned by extension id, followed by another level of directories |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 | 611 |
| 596 // Add content's URLRequestContext's hooks. | 612 // Add content's URLRequestContext's hooks. |
| 597 BrowserThread::PostTask( | 613 BrowserThread::PostTask( |
| 598 BrowserThread::IO, FROM_HERE, | 614 BrowserThread::IO, FROM_HERE, |
| 599 base::Bind( | 615 base::Bind( |
| 600 &InitializeURLRequestContext, | 616 &InitializeURLRequestContext, |
| 601 make_scoped_refptr(partition->GetURLRequestContext()), | 617 make_scoped_refptr(partition->GetURLRequestContext()), |
| 602 make_scoped_refptr(partition->GetAppCacheService()), | 618 make_scoped_refptr(partition->GetAppCacheService()), |
| 603 make_scoped_refptr(partition->GetFileSystemContext()), | 619 make_scoped_refptr(partition->GetFileSystemContext()), |
| 604 make_scoped_refptr( | 620 make_scoped_refptr( |
| 605 ChromeBlobStorageContext::GetFor(browser_context_)))); | 621 ChromeBlobStorageContext::GetFor(browser_context_)), |
| 622 browser_context_->GetResourceContext(), |
| 623 browser_context_->IsOffTheRecord())); |
| 606 | 624 |
| 607 // We do not call InitializeURLRequestContext() for media contexts because, | 625 // We do not call InitializeURLRequestContext() for media contexts because, |
| 608 // other than the HTTP cache, the media contexts share the same backing | 626 // other than the HTTP cache, the media contexts share the same backing |
| 609 // objects as their associated "normal" request context. Thus, the previous | 627 // objects as their associated "normal" request context. Thus, the previous |
| 610 // call serves to initialize the media request context for this storage | 628 // call serves to initialize the media request context for this storage |
| 611 // partition as well. | 629 // partition as well. |
| 612 } | 630 } |
| 613 } | 631 } |
| 614 | 632 |
| 615 } // namespace content | 633 } // namespace content |
| OLD | NEW |