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

Side by Side Diff: content/browser/service_worker/service_worker_response_info.cc

Issue 2815913005: Switch to using scoped_ptr with UserData (Closed)
Patch Set: rebase Created 3 years, 8 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
OLDNEW
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
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
OLDNEW
« no previous file with comments | « content/browser/service_worker/foreign_fetch_request_handler.cc ('k') | content/browser/ssl/ssl_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698