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

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

Issue 1108273002: Add Client Attribute to FetchEvent- Chromium Side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_listener.h" 5 #include "content/browser/cache_storage/cache_storage_listener.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "content/browser/cache_storage/cache_storage_cache.h" 10 #include "content/browser/cache_storage/cache_storage_cache.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 int thread_id, 152 int thread_id,
153 int request_id, 153 int request_id,
154 const GURL& origin, 154 const GURL& origin,
155 const ServiceWorkerFetchRequest& request, 155 const ServiceWorkerFetchRequest& request,
156 const CacheStorageCacheQueryParams& match_params) { 156 const CacheStorageCacheQueryParams& match_params) {
157 TRACE_EVENT0("CacheStorage", "CacheStorageListener::OnCacheStorageMatch"); 157 TRACE_EVENT0("CacheStorage", "CacheStorageListener::OnCacheStorageMatch");
158 158
159 scoped_ptr<ServiceWorkerFetchRequest> scoped_request( 159 scoped_ptr<ServiceWorkerFetchRequest> scoped_request(
160 new ServiceWorkerFetchRequest(request.url, request.method, 160 new ServiceWorkerFetchRequest(request.url, request.method,
161 request.headers, request.referrer, 161 request.headers, request.referrer,
162 request.is_reload)); 162 request.is_reload, request.client));
163 163
164 if (match_params.cache_name.empty()) { 164 if (match_params.cache_name.empty()) {
165 context_->cache_manager()->MatchAllCaches( 165 context_->cache_manager()->MatchAllCaches(
166 origin, scoped_request.Pass(), 166 origin, scoped_request.Pass(),
167 base::Bind(&CacheStorageListener::OnCacheStorageMatchCallback, 167 base::Bind(&CacheStorageListener::OnCacheStorageMatchCallback,
168 weak_factory_.GetWeakPtr(), thread_id, request_id)); 168 weak_factory_.GetWeakPtr(), thread_id, request_id));
169 return; 169 return;
170 } 170 }
171 context_->cache_manager()->MatchCache( 171 context_->cache_manager()->MatchCache(
172 origin, base::UTF16ToUTF8(match_params.cache_name), scoped_request.Pass(), 172 origin, base::UTF16ToUTF8(match_params.cache_name), scoped_request.Pass(),
(...skipping 11 matching lines...) Expand all
184 if (it == id_to_cache_map_.end()) { 184 if (it == id_to_cache_map_.end()) {
185 Send(new CacheStorageMsg_CacheMatchError( 185 Send(new CacheStorageMsg_CacheMatchError(
186 thread_id, request_id, blink::WebServiceWorkerCacheErrorNotFound)); 186 thread_id, request_id, blink::WebServiceWorkerCacheErrorNotFound));
187 return; 187 return;
188 } 188 }
189 189
190 scoped_refptr<CacheStorageCache> cache = it->second; 190 scoped_refptr<CacheStorageCache> cache = it->second;
191 scoped_ptr<ServiceWorkerFetchRequest> scoped_request( 191 scoped_ptr<ServiceWorkerFetchRequest> scoped_request(
192 new ServiceWorkerFetchRequest(request.url, request.method, 192 new ServiceWorkerFetchRequest(request.url, request.method,
193 request.headers, request.referrer, 193 request.headers, request.referrer,
194 request.is_reload)); 194 request.is_reload, request.client));
195 cache->Match( 195 cache->Match(
196 scoped_request.Pass(), 196 scoped_request.Pass(),
197 base::Bind(&CacheStorageListener::OnCacheMatchCallback, 197 base::Bind(&CacheStorageListener::OnCacheMatchCallback,
198 weak_factory_.GetWeakPtr(), thread_id, request_id, cache)); 198 weak_factory_.GetWeakPtr(), thread_id, request_id, cache));
199 } 199 }
200 200
201 void CacheStorageListener::OnCacheMatchAll( 201 void CacheStorageListener::OnCacheMatchAll(
202 int thread_id, 202 int thread_id,
203 int request_id, 203 int request_id,
204 int cache_id, 204 int cache_id,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 return; 248 return;
249 } 249 }
250 250
251 const CacheStorageBatchOperation& operation = operations[0]; 251 const CacheStorageBatchOperation& operation = operations[0];
252 252
253 scoped_refptr<CacheStorageCache> cache = it->second; 253 scoped_refptr<CacheStorageCache> cache = it->second;
254 scoped_ptr<ServiceWorkerFetchRequest> scoped_request( 254 scoped_ptr<ServiceWorkerFetchRequest> scoped_request(
255 new ServiceWorkerFetchRequest( 255 new ServiceWorkerFetchRequest(
256 operation.request.url, operation.request.method, 256 operation.request.url, operation.request.method,
257 operation.request.headers, operation.request.referrer, 257 operation.request.headers, operation.request.referrer,
258 operation.request.is_reload)); 258 operation.request.is_reload, operation.request.client));
259 259
260 if (operation.operation_type == CACHE_STORAGE_CACHE_OPERATION_TYPE_DELETE) { 260 if (operation.operation_type == CACHE_STORAGE_CACHE_OPERATION_TYPE_DELETE) {
261 cache->Delete( 261 cache->Delete(
262 scoped_request.Pass(), 262 scoped_request.Pass(),
263 base::Bind(&CacheStorageListener::OnCacheDeleteCallback, 263 base::Bind(&CacheStorageListener::OnCacheDeleteCallback,
264 weak_factory_.GetWeakPtr(), thread_id, request_id, cache)); 264 weak_factory_.GetWeakPtr(), thread_id, request_id, cache));
265 return; 265 return;
266 } 266 }
267 267
268 if (operation.operation_type == CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT) { 268 if (operation.operation_type == CACHE_STORAGE_CACHE_OPERATION_TYPE_PUT) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 Send(new CacheStorageMsg_CacheKeysError( 410 Send(new CacheStorageMsg_CacheKeysError(
411 thread_id, request_id, CacheErrorToWebServiceWorkerCacheError(error))); 411 thread_id, request_id, CacheErrorToWebServiceWorkerCacheError(error)));
412 return; 412 return;
413 } 413 }
414 414
415 CacheStorageCache::Requests out; 415 CacheStorageCache::Requests out;
416 416
417 for (CacheStorageCache::Requests::const_iterator it = requests->begin(); 417 for (CacheStorageCache::Requests::const_iterator it = requests->begin();
418 it != requests->end(); ++it) { 418 it != requests->end(); ++it) {
419 ServiceWorkerFetchRequest request(it->url, it->method, it->headers, 419 ServiceWorkerFetchRequest request(it->url, it->method, it->headers,
420 it->referrer, it->is_reload); 420 it->referrer, it->is_reload, it->client);
421 out.push_back(request); 421 out.push_back(request);
422 } 422 }
423 423
424 Send(new CacheStorageMsg_CacheKeysSuccess(thread_id, request_id, out)); 424 Send(new CacheStorageMsg_CacheKeysSuccess(thread_id, request_id, out));
425 } 425 }
426 426
427 void CacheStorageListener::OnCacheDeleteCallback( 427 void CacheStorageListener::OnCacheDeleteCallback(
428 int thread_id, 428 int thread_id,
429 int request_id, 429 int request_id,
430 const scoped_refptr<CacheStorageCache>& cache, 430 const scoped_refptr<CacheStorageCache>& cache,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 UUIDToBlobDataHandleList::iterator it = blob_handle_store_.find(uuid); 484 UUIDToBlobDataHandleList::iterator it = blob_handle_store_.find(uuid);
485 if (it == blob_handle_store_.end()) 485 if (it == blob_handle_store_.end())
486 return; 486 return;
487 DCHECK(!it->second.empty()); 487 DCHECK(!it->second.empty());
488 it->second.pop_front(); 488 it->second.pop_front();
489 if (it->second.empty()) 489 if (it->second.empty())
490 blob_handle_store_.erase(it); 490 blob_handle_store_.erase(it);
491 } 491 }
492 492
493 } // namespace content 493 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698