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

Side by Side Diff: content/browser/cache_storage/cache_storage_dispatcher_host.cc

Issue 2385533002: Replace usage of GURL(origin.Serialize()) with origin.GetURL() (Closed)
Patch Set: sync to #424762 Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/cache_storage/cache_storage_dispatcher_host.h" 5 #include "content/browser/cache_storage/cache_storage_dispatcher_host.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 case CACHE_STORAGE_ERROR_CACHE_NAME_NOT_FOUND: 54 case CACHE_STORAGE_ERROR_CACHE_NAME_NOT_FOUND:
55 return blink::WebServiceWorkerCacheErrorCacheNameNotFound; 55 return blink::WebServiceWorkerCacheErrorCacheNameNotFound;
56 case CACHE_STORAGE_ERROR_QUERY_TOO_LARGE: 56 case CACHE_STORAGE_ERROR_QUERY_TOO_LARGE:
57 return blink::WebServiceWorkerCacheErrorTooLarge; 57 return blink::WebServiceWorkerCacheErrorTooLarge;
58 } 58 }
59 NOTREACHED(); 59 NOTREACHED();
60 return blink::WebServiceWorkerCacheErrorNotImplemented; 60 return blink::WebServiceWorkerCacheErrorNotImplemented;
61 } 61 }
62 62
63 bool OriginCanAccessCacheStorage(const url::Origin& origin) { 63 bool OriginCanAccessCacheStorage(const url::Origin& origin) {
64 return !origin.unique() && IsOriginSecure(GURL(origin.Serialize())); 64 return !origin.unique() && IsOriginSecure(origin.GetURL());
65 } 65 }
66 66
67 void StopPreservingCache( 67 void StopPreservingCache(
68 std::unique_ptr<CacheStorageCacheHandle> cache_handle) {} 68 std::unique_ptr<CacheStorageCacheHandle> cache_handle) {}
69 69
70 } // namespace 70 } // namespace
71 71
72 CacheStorageDispatcherHost::CacheStorageDispatcherHost() 72 CacheStorageDispatcherHost::CacheStorageDispatcherHost()
73 : BrowserMessageFilter(kFilteredMessageClasses, 73 : BrowserMessageFilter(kFilteredMessageClasses,
74 arraysize(kFilteredMessageClasses)) {} 74 arraysize(kFilteredMessageClasses)) {}
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 int thread_id, 125 int thread_id,
126 int request_id, 126 int request_id,
127 const url::Origin& origin, 127 const url::Origin& origin,
128 const base::string16& cache_name) { 128 const base::string16& cache_name) {
129 TRACE_EVENT0("CacheStorage", "CacheStorageDispatcherHost::OnCacheStorageHas"); 129 TRACE_EVENT0("CacheStorage", "CacheStorageDispatcherHost::OnCacheStorageHas");
130 if (!OriginCanAccessCacheStorage(origin)) { 130 if (!OriginCanAccessCacheStorage(origin)) {
131 bad_message::ReceivedBadMessage(this, bad_message::CSDH_INVALID_ORIGIN); 131 bad_message::ReceivedBadMessage(this, bad_message::CSDH_INVALID_ORIGIN);
132 return; 132 return;
133 } 133 }
134 context_->cache_manager()->HasCache( 134 context_->cache_manager()->HasCache(
135 GURL(origin.Serialize()), base::UTF16ToUTF8(cache_name), 135 origin.GetURL(), base::UTF16ToUTF8(cache_name),
136 base::Bind(&CacheStorageDispatcherHost::OnCacheStorageHasCallback, this, 136 base::Bind(&CacheStorageDispatcherHost::OnCacheStorageHasCallback, this,
137 thread_id, request_id)); 137 thread_id, request_id));
138 } 138 }
139 139
140 void CacheStorageDispatcherHost::OnCacheStorageOpen( 140 void CacheStorageDispatcherHost::OnCacheStorageOpen(
141 int thread_id, 141 int thread_id,
142 int request_id, 142 int request_id,
143 const url::Origin& origin, 143 const url::Origin& origin,
144 const base::string16& cache_name) { 144 const base::string16& cache_name) {
145 TRACE_EVENT0("CacheStorage", 145 TRACE_EVENT0("CacheStorage",
146 "CacheStorageDispatcherHost::OnCacheStorageOpen"); 146 "CacheStorageDispatcherHost::OnCacheStorageOpen");
147 if (!OriginCanAccessCacheStorage(origin)) { 147 if (!OriginCanAccessCacheStorage(origin)) {
148 bad_message::ReceivedBadMessage(this, bad_message::CSDH_INVALID_ORIGIN); 148 bad_message::ReceivedBadMessage(this, bad_message::CSDH_INVALID_ORIGIN);
149 return; 149 return;
150 } 150 }
151 context_->cache_manager()->OpenCache( 151 context_->cache_manager()->OpenCache(
152 GURL(origin.Serialize()), base::UTF16ToUTF8(cache_name), 152 origin.GetURL(), base::UTF16ToUTF8(cache_name),
153 base::Bind(&CacheStorageDispatcherHost::OnCacheStorageOpenCallback, this, 153 base::Bind(&CacheStorageDispatcherHost::OnCacheStorageOpenCallback, this,
154 thread_id, request_id)); 154 thread_id, request_id));
155 } 155 }
156 156
157 void CacheStorageDispatcherHost::OnCacheStorageDelete( 157 void CacheStorageDispatcherHost::OnCacheStorageDelete(
158 int thread_id, 158 int thread_id,
159 int request_id, 159 int request_id,
160 const url::Origin& origin, 160 const url::Origin& origin,
161 const base::string16& cache_name) { 161 const base::string16& cache_name) {
162 TRACE_EVENT0("CacheStorage", 162 TRACE_EVENT0("CacheStorage",
163 "CacheStorageDispatcherHost::OnCacheStorageDelete"); 163 "CacheStorageDispatcherHost::OnCacheStorageDelete");
164 if (!OriginCanAccessCacheStorage(origin)) { 164 if (!OriginCanAccessCacheStorage(origin)) {
165 bad_message::ReceivedBadMessage(this, bad_message::CSDH_INVALID_ORIGIN); 165 bad_message::ReceivedBadMessage(this, bad_message::CSDH_INVALID_ORIGIN);
166 return; 166 return;
167 } 167 }
168 context_->cache_manager()->DeleteCache( 168 context_->cache_manager()->DeleteCache(
169 GURL(origin.Serialize()), base::UTF16ToUTF8(cache_name), 169 origin.GetURL(), base::UTF16ToUTF8(cache_name),
170 base::Bind(&CacheStorageDispatcherHost::OnCacheStorageDeleteCallback, 170 base::Bind(&CacheStorageDispatcherHost::OnCacheStorageDeleteCallback,
171 this, thread_id, request_id)); 171 this, thread_id, request_id));
172 } 172 }
173 173
174 void CacheStorageDispatcherHost::OnCacheStorageKeys(int thread_id, 174 void CacheStorageDispatcherHost::OnCacheStorageKeys(int thread_id,
175 int request_id, 175 int request_id,
176 const url::Origin& origin) { 176 const url::Origin& origin) {
177 TRACE_EVENT0("CacheStorage", 177 TRACE_EVENT0("CacheStorage",
178 "CacheStorageDispatcherHost::OnCacheStorageKeys"); 178 "CacheStorageDispatcherHost::OnCacheStorageKeys");
179 if (!OriginCanAccessCacheStorage(origin)) { 179 if (!OriginCanAccessCacheStorage(origin)) {
180 bad_message::ReceivedBadMessage(this, bad_message::CSDH_INVALID_ORIGIN); 180 bad_message::ReceivedBadMessage(this, bad_message::CSDH_INVALID_ORIGIN);
181 return; 181 return;
182 } 182 }
183 context_->cache_manager()->EnumerateCaches( 183 context_->cache_manager()->EnumerateCaches(
184 GURL(origin.Serialize()), 184 origin.GetURL(),
185 base::Bind(&CacheStorageDispatcherHost::OnCacheStorageKeysCallback, this, 185 base::Bind(&CacheStorageDispatcherHost::OnCacheStorageKeysCallback, this,
186 thread_id, request_id)); 186 thread_id, request_id));
187 } 187 }
188 188
189 void CacheStorageDispatcherHost::OnCacheStorageMatch( 189 void CacheStorageDispatcherHost::OnCacheStorageMatch(
190 int thread_id, 190 int thread_id,
191 int request_id, 191 int request_id,
192 const url::Origin& origin, 192 const url::Origin& origin,
193 const ServiceWorkerFetchRequest& request, 193 const ServiceWorkerFetchRequest& request,
194 const CacheStorageCacheQueryParams& match_params) { 194 const CacheStorageCacheQueryParams& match_params) {
195 TRACE_EVENT0("CacheStorage", 195 TRACE_EVENT0("CacheStorage",
196 "CacheStorageDispatcherHost::OnCacheStorageMatch"); 196 "CacheStorageDispatcherHost::OnCacheStorageMatch");
197 if (!OriginCanAccessCacheStorage(origin)) { 197 if (!OriginCanAccessCacheStorage(origin)) {
198 bad_message::ReceivedBadMessage(this, bad_message::CSDH_INVALID_ORIGIN); 198 bad_message::ReceivedBadMessage(this, bad_message::CSDH_INVALID_ORIGIN);
199 return; 199 return;
200 } 200 }
201 std::unique_ptr<ServiceWorkerFetchRequest> scoped_request( 201 std::unique_ptr<ServiceWorkerFetchRequest> scoped_request(
202 new ServiceWorkerFetchRequest(request.url, request.method, 202 new ServiceWorkerFetchRequest(request.url, request.method,
203 request.headers, request.referrer, 203 request.headers, request.referrer,
204 request.is_reload)); 204 request.is_reload));
205 205
206 if (match_params.cache_name.is_null()) { 206 if (match_params.cache_name.is_null()) {
207 context_->cache_manager()->MatchAllCaches( 207 context_->cache_manager()->MatchAllCaches(
208 GURL(origin.Serialize()), std::move(scoped_request), match_params, 208 origin.GetURL(), std::move(scoped_request), match_params,
209 base::Bind(&CacheStorageDispatcherHost::OnCacheStorageMatchCallback, 209 base::Bind(&CacheStorageDispatcherHost::OnCacheStorageMatchCallback,
210 this, thread_id, request_id)); 210 this, thread_id, request_id));
211 return; 211 return;
212 } 212 }
213 context_->cache_manager()->MatchCache( 213 context_->cache_manager()->MatchCache(
214 GURL(origin.Serialize()), 214 origin.GetURL(), base::UTF16ToUTF8(match_params.cache_name.string()),
215 base::UTF16ToUTF8(match_params.cache_name.string()),
216 std::move(scoped_request), match_params, 215 std::move(scoped_request), match_params,
217 base::Bind(&CacheStorageDispatcherHost::OnCacheStorageMatchCallback, this, 216 base::Bind(&CacheStorageDispatcherHost::OnCacheStorageMatchCallback, this,
218 thread_id, request_id)); 217 thread_id, request_id));
219 } 218 }
220 219
221 void CacheStorageDispatcherHost::OnCacheMatch( 220 void CacheStorageDispatcherHost::OnCacheMatch(
222 int thread_id, 221 int thread_id,
223 int request_id, 222 int request_id,
224 int cache_id, 223 int cache_id,
225 const ServiceWorkerFetchRequest& request, 224 const ServiceWorkerFetchRequest& request,
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 UUIDToBlobDataHandleList::iterator it = blob_handle_store_.find(uuid); 538 UUIDToBlobDataHandleList::iterator it = blob_handle_store_.find(uuid);
540 if (it == blob_handle_store_.end()) 539 if (it == blob_handle_store_.end())
541 return; 540 return;
542 DCHECK(!it->second.empty()); 541 DCHECK(!it->second.empty());
543 it->second.pop_front(); 542 it->second.pop_front();
544 if (it->second.empty()) 543 if (it->second.empty())
545 blob_handle_store_.erase(it); 544 blob_handle_store_.erase(it);
546 } 545 }
547 546
548 } // namespace content 547 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698