| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/appcache/appcache_url_loader_factory.h" | 5 #include "content/browser/appcache/appcache_url_loader_factory.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "content/browser/appcache/appcache_entry.h" | 9 #include "content/browser/appcache/appcache_entry.h" |
| 10 #include "content/browser/appcache/appcache_policy.h" | 10 #include "content/browser/appcache/appcache_policy.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // Handles AppCache URL loads for the network service. | 28 // Handles AppCache URL loads for the network service. |
| 29 class AppCacheURLLoader : public AppCacheStorage::Delegate, | 29 class AppCacheURLLoader : public AppCacheStorage::Delegate, |
| 30 public mojom::URLLoader { | 30 public mojom::URLLoader { |
| 31 public: | 31 public: |
| 32 AppCacheURLLoader(const ResourceRequest& request, | 32 AppCacheURLLoader(const ResourceRequest& request, |
| 33 mojom::URLLoaderAssociatedRequest url_loader_request, | |
| 34 int32_t routing_id, | 33 int32_t routing_id, |
| 35 int32_t request_id, | 34 int32_t request_id, |
| 36 mojom::URLLoaderClientPtr client_info, | |
| 37 ChromeAppCacheService* appcache_service, | 35 ChromeAppCacheService* appcache_service, |
| 38 URLLoaderFactoryGetter* factory_getter) | 36 URLLoaderFactoryGetter* factory_getter) |
| 39 : request_(request), | 37 : request_(request), |
| 40 routing_id_(routing_id), | 38 routing_id_(routing_id), |
| 41 request_id_(request_id), | 39 request_id_(request_id), |
| 42 client_info_(std::move(client_info)), | |
| 43 appcache_service_(appcache_service), | 40 appcache_service_(appcache_service), |
| 44 factory_getter_(factory_getter), | 41 factory_getter_(factory_getter), |
| 45 binding_(this, std::move(url_loader_request)) { | 42 binding_(this) {} |
| 46 binding_.set_connection_error_handler(base::Bind( | |
| 47 &AppCacheURLLoader::OnConnectionError, base::Unretained(this))); | |
| 48 } | |
| 49 | 43 |
| 50 ~AppCacheURLLoader() override {} | 44 ~AppCacheURLLoader() override {} |
| 51 | 45 |
| 52 void Start() { | 46 void Start(mojom::URLLoaderAssociatedRequest url_loader_request, |
| 47 mojom::URLLoaderClientPtr client_info) override { |
| 48 binding_.Bind(std::move(url_loader_request)); |
| 49 binding_.set_connection_error_handler(base::Bind( |
| 50 &AppCacheURLLoader::OnConnectionError, base::Unretained(this))); |
| 51 client_info_ = std::move(client_info); |
| 53 // If the origin does not exist in the AppCache usage map, then we can | 52 // If the origin does not exist in the AppCache usage map, then we can |
| 54 // safely call the network service here. | 53 // safely call the network service here. |
| 55 if (appcache_service_->storage()->usage_map()->find( | 54 if (appcache_service_->storage()->usage_map()->find( |
| 56 request_.url.GetOrigin()) == | 55 request_.url.GetOrigin()) == |
| 57 appcache_service_->storage()->usage_map()->end()) { | 56 appcache_service_->storage()->usage_map()->end()) { |
| 58 factory_getter_->GetNetworkFactory()->get()->CreateLoaderAndStart( | 57 factory_getter_->GetNetworkFactory()->get()->CreateLoaderAndStart( |
| 59 mojo::MakeRequest(&network_loader_request_), routing_id_, request_id_, | 58 mojo::MakeRequest(&network_loader_request_), routing_id_, request_id_, |
| 60 mojom::kURLLoadOptionSendSSLInfo, request_, std::move(client_info_)); | 59 mojom::kURLLoadOptionSendSSLInfo, request_, std::move(client_info_)); |
| 61 return; | 60 return; |
| 62 } | 61 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 void AppCacheURLLoaderFactory::CreateLoaderAndStart( | 161 void AppCacheURLLoaderFactory::CreateLoaderAndStart( |
| 163 mojom::URLLoaderAssociatedRequest url_loader_request, | 162 mojom::URLLoaderAssociatedRequest url_loader_request, |
| 164 int32_t routing_id, | 163 int32_t routing_id, |
| 165 int32_t request_id, | 164 int32_t request_id, |
| 166 uint32_t options, | 165 uint32_t options, |
| 167 const ResourceRequest& request, | 166 const ResourceRequest& request, |
| 168 mojom::URLLoaderClientPtr client) { | 167 mojom::URLLoaderClientPtr client) { |
| 169 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 168 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 170 | 169 |
| 171 // This will get deleted when the connection is dropped by the client. | 170 // This will get deleted when the connection is dropped by the client. |
| 172 AppCacheURLLoader* loader = new AppCacheURLLoader( | 171 AppCacheURLLoader* loader = |
| 173 request, std::move(url_loader_request), routing_id, request_id, | 172 new AppCacheURLLoader(request, routing_id, request_id, |
| 174 std::move(client), appcache_service_.get(), factory_getter_.get()); | 173 appcache_service_.get(), factory_getter_.get()); |
| 175 loader->Start(); | 174 loader->Start(std::move(url_loader_request), std::move(client)); |
| 176 } | 175 } |
| 177 | 176 |
| 178 void AppCacheURLLoaderFactory::SyncLoad(int32_t routing_id, | 177 void AppCacheURLLoaderFactory::SyncLoad(int32_t routing_id, |
| 179 int32_t request_id, | 178 int32_t request_id, |
| 180 const ResourceRequest& request, | 179 const ResourceRequest& request, |
| 181 SyncLoadCallback callback) { | 180 SyncLoadCallback callback) { |
| 182 NOTREACHED(); | 181 NOTREACHED(); |
| 183 } | 182 } |
| 184 | 183 |
| 185 } // namespace content | 184 } // namespace content |
| OLD | NEW |