| 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 "base/memory/ptr_util.h" | 
| 8 #include "content/public/common/resource_response_info.h" | 8 #include "content/public/common/resource_response_info.h" | 
| 9 #include "net/url_request/url_request.h" | 9 #include "net/url_request/url_request.h" | 
| 10 | 10 | 
| 11 namespace content { | 11 namespace content { | 
| 12 | 12 | 
| 13 namespace { | 13 namespace { | 
| 14 | 14 | 
| 15 int kUserDataKey;  // Only address is used, value is not important. | 15 int kSW3UserDataKey;  // Only address is used, value is not important. | 
| 16 | 16 | 
| 17 }  // namespace | 17 }  // namespace | 
| 18 | 18 | 
| 19 // static | 19 // static | 
| 20 ServiceWorkerResponseInfo* ServiceWorkerResponseInfo::ForRequest( | 20 ServiceWorkerResponseInfo* ServiceWorkerResponseInfo::ForRequest( | 
| 21     net::URLRequest* request, | 21     net::URLRequest* request, | 
| 22     bool create) { | 22     bool create) { | 
| 23   ServiceWorkerResponseInfo* info = static_cast<ServiceWorkerResponseInfo*>( | 23   ServiceWorkerResponseInfo* info = static_cast<ServiceWorkerResponseInfo*>( | 
| 24       request->GetUserData(&kUserDataKey)); | 24       request->GetUserData(&kSW3UserDataKey)); | 
| 25   if (!info && create) { | 25   if (!info && create) { | 
| 26     info = new ServiceWorkerResponseInfo(); | 26     info = new ServiceWorkerResponseInfo(); | 
| 27     request->SetUserData(&kUserDataKey, base::WrapUnique(info)); | 27     request->SetUserData(&kSW3UserDataKey, base::WrapUnique(info)); | 
| 28   } | 28   } | 
| 29   return info; | 29   return info; | 
| 30 } | 30 } | 
| 31 | 31 | 
| 32 // static | 32 // static | 
| 33 void ServiceWorkerResponseInfo::ResetDataForRequest(net::URLRequest* request) { | 33 void ServiceWorkerResponseInfo::ResetDataForRequest(net::URLRequest* request) { | 
| 34   ServiceWorkerResponseInfo* info = ForRequest(request); | 34   ServiceWorkerResponseInfo* info = ForRequest(request); | 
| 35   if (info) | 35   if (info) | 
| 36     info->ResetData(); | 36     info->ResetData(); | 
| 37 } | 37 } | 
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 119   response_cache_storage_cache_name_ = std::string(); | 119   response_cache_storage_cache_name_ = std::string(); | 
| 120   cors_exposed_header_names_.clear(); | 120   cors_exposed_header_names_.clear(); | 
| 121   // 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 | 
| 122   // 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 | 
| 123   // even if the job restarts. | 123   // even if the job restarts. | 
| 124 } | 124 } | 
| 125 | 125 | 
| 126 ServiceWorkerResponseInfo::ServiceWorkerResponseInfo() {} | 126 ServiceWorkerResponseInfo::ServiceWorkerResponseInfo() {} | 
| 127 | 127 | 
| 128 }  // namespace content | 128 }  // namespace content | 
| OLD | NEW | 
|---|