| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/service_worker/service_worker_response_info.h" | 5 #include "content/browser/service_worker/service_worker_response_info.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
| 7 #include "content/public/common/resource_response_info.h" | 8 #include "content/public/common/resource_response_info.h" |
| 8 #include "net/url_request/url_request.h" | 9 #include "net/url_request/url_request.h" |
| 9 | 10 |
| 10 namespace content { | 11 namespace content { |
| 11 | 12 |
| 12 namespace { | 13 namespace { |
| 13 | 14 |
| 14 int kUserDataKey; // Only address is used, value is not important. | 15 int kUserDataKey; // Only address is used, value is not important. |
| 15 | 16 |
| 16 } // namespace | 17 } // namespace |
| 17 | 18 |
| 18 // static | 19 // static |
| 19 ServiceWorkerResponseInfo* ServiceWorkerResponseInfo::ForRequest( | 20 ServiceWorkerResponseInfo* ServiceWorkerResponseInfo::ForRequest( |
| 20 net::URLRequest* request, | 21 net::URLRequest* request, |
| 21 bool create) { | 22 bool create) { |
| 22 ServiceWorkerResponseInfo* info = static_cast<ServiceWorkerResponseInfo*>( | 23 ServiceWorkerResponseInfo* info = static_cast<ServiceWorkerResponseInfo*>( |
| 23 request->GetUserData(&kUserDataKey)); | 24 request->GetUserData(&kUserDataKey)); |
| 24 if (!info && create) { | 25 if (!info && create) { |
| 25 info = new ServiceWorkerResponseInfo(); | 26 info = new ServiceWorkerResponseInfo(); |
| 26 request->SetUserData(&kUserDataKey, info); | 27 request->SetUserData(&kUserDataKey, base::WrapUnique(info)); |
| 27 } | 28 } |
| 28 return info; | 29 return info; |
| 29 } | 30 } |
| 30 | 31 |
| 31 // static | 32 // static |
| 32 void ServiceWorkerResponseInfo::ResetDataForRequest(net::URLRequest* request) { | 33 void ServiceWorkerResponseInfo::ResetDataForRequest(net::URLRequest* request) { |
| 33 ServiceWorkerResponseInfo* info = ForRequest(request); | 34 ServiceWorkerResponseInfo* info = ForRequest(request); |
| 34 if (info) | 35 if (info) |
| 35 info->ResetData(); | 36 info->ResetData(); |
| 36 } | 37 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 response_cache_storage_cache_name_ = std::string(); | 119 response_cache_storage_cache_name_ = std::string(); |
| 119 cors_exposed_header_names_.clear(); | 120 cors_exposed_header_names_.clear(); |
| 120 // Don't reset the |did_navigation_preload_| flag. This is used for the | 121 // Don't reset the |did_navigation_preload_| flag. This is used for the |
| 121 // UseCounter, and if it was ever true for a request, it should remain true | 122 // UseCounter, and if it was ever true for a request, it should remain true |
| 122 // even if the job restarts. | 123 // even if the job restarts. |
| 123 } | 124 } |
| 124 | 125 |
| 125 ServiceWorkerResponseInfo::ServiceWorkerResponseInfo() {} | 126 ServiceWorkerResponseInfo::ServiceWorkerResponseInfo() {} |
| 126 | 127 |
| 127 } // namespace content | 128 } // namespace content |
| OLD | NEW |