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

Side by Side Diff: third_party/WebKit/Source/modules/cachestorage/InspectorCacheStorageAgent.cpp

Issue 2004313003: DevTools: migrate from OwnPtr to std::unique_ptr for inspector protocol classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaselined Created 4 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 "modules/cachestorage/InspectorCacheStorageAgent.h" 5 #include "modules/cachestorage/InspectorCacheStorageAgent.h"
6 #include "platform/heap/Handle.h" 6 #include "platform/heap/Handle.h"
7 #include "platform/inspector_protocol/Dispatcher.h" 7 #include "platform/inspector_protocol/Dispatcher.h"
8 #include "platform/inspector_protocol/TypeBuilder.h" 8 #include "platform/inspector_protocol/TypeBuilder.h"
9 #include "platform/inspector_protocol/Values.h" 9 #include "platform/inspector_protocol/Values.h"
10 #include "platform/weborigin/KURL.h" 10 #include "platform/weborigin/KURL.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 return CString("unknown error."); 106 return CString("unknown error.");
107 break; 107 break;
108 } 108 }
109 } 109 }
110 110
111 class RequestCacheNames 111 class RequestCacheNames
112 : public WebServiceWorkerCacheStorage::CacheStorageKeysCallbacks { 112 : public WebServiceWorkerCacheStorage::CacheStorageKeysCallbacks {
113 WTF_MAKE_NONCOPYABLE(RequestCacheNames); 113 WTF_MAKE_NONCOPYABLE(RequestCacheNames);
114 114
115 public: 115 public:
116 RequestCacheNames(const String& securityOrigin, PassOwnPtr<RequestCacheNames Callback> callback) 116 RequestCacheNames(const String& securityOrigin, std::unique_ptr<RequestCache NamesCallback> callback)
117 : m_securityOrigin(securityOrigin) 117 : m_securityOrigin(securityOrigin)
118 , m_callback(std::move(callback)) 118 , m_callback(std::move(callback))
119 { 119 {
120 } 120 }
121 121
122 ~RequestCacheNames() override { } 122 ~RequestCacheNames() override { }
123 123
124 void onSuccess(const WebVector<WebString>& caches) override 124 void onSuccess(const WebVector<WebString>& caches) override
125 { 125 {
126 OwnPtr<Array<Cache>> array = Array<Cache>::create(); 126 std::unique_ptr<Array<Cache>> array = Array<Cache>::create();
127 for (size_t i = 0; i < caches.size(); i++) { 127 for (size_t i = 0; i < caches.size(); i++) {
128 String name = String(caches[i]); 128 String name = String(caches[i]);
129 OwnPtr<Cache> entry = Cache::create() 129 std::unique_ptr<Cache> entry = Cache::create()
130 .setSecurityOrigin(m_securityOrigin) 130 .setSecurityOrigin(m_securityOrigin)
131 .setCacheName(name) 131 .setCacheName(name)
132 .setCacheId(buildCacheId(m_securityOrigin, name)).build(); 132 .setCacheId(buildCacheId(m_securityOrigin, name)).build();
133 array->addItem(std::move(entry)); 133 array->addItem(std::move(entry));
134 } 134 }
135 m_callback->sendSuccess(std::move(array)); 135 m_callback->sendSuccess(std::move(array));
136 } 136 }
137 137
138 void onError(WebServiceWorkerCacheError error) override 138 void onError(WebServiceWorkerCacheError error) override
139 { 139 {
140 m_callback->sendFailure(String::format("Error requesting cache names: %s ", serviceWorkerCacheErrorString(error).data())); 140 m_callback->sendFailure(String::format("Error requesting cache names: %s ", serviceWorkerCacheErrorString(error).data()));
141 } 141 }
142 142
143 private: 143 private:
144 String m_securityOrigin; 144 String m_securityOrigin;
145 OwnPtr<RequestCacheNamesCallback> m_callback; 145 std::unique_ptr<RequestCacheNamesCallback> m_callback;
146 }; 146 };
147 147
148 struct DataRequestParams { 148 struct DataRequestParams {
149 String cacheName; 149 String cacheName;
150 int skipCount; 150 int skipCount;
151 int pageSize; 151 int pageSize;
152 }; 152 };
153 153
154 struct RequestResponse { 154 struct RequestResponse {
155 RequestResponse() { } 155 RequestResponse() { }
156 RequestResponse(const String& request, const String& response) 156 RequestResponse(const String& request, const String& response)
157 : request(request) 157 : request(request)
158 , response(response) 158 , response(response)
159 { 159 {
160 } 160 }
161 String request; 161 String request;
162 String response; 162 String response;
163 }; 163 };
164 164
165 class ResponsesAccumulator : public RefCounted<ResponsesAccumulator> { 165 class ResponsesAccumulator : public RefCounted<ResponsesAccumulator> {
166 WTF_MAKE_NONCOPYABLE(ResponsesAccumulator); 166 WTF_MAKE_NONCOPYABLE(ResponsesAccumulator);
167 167
168 public: 168 public:
169 ResponsesAccumulator(int numResponses, const DataRequestParams& params, Pass OwnPtr<RequestEntriesCallback> callback) 169 ResponsesAccumulator(int numResponses, const DataRequestParams& params, std: :unique_ptr<RequestEntriesCallback> callback)
170 : m_params(params) 170 : m_params(params)
171 , m_numResponsesLeft(numResponses) 171 , m_numResponsesLeft(numResponses)
172 , m_responses(static_cast<size_t>(numResponses)) 172 , m_responses(static_cast<size_t>(numResponses))
173 , m_callback(std::move(callback)) 173 , m_callback(std::move(callback))
174 { 174 {
175 } 175 }
176 176
177 void addRequestResponsePair(const WebServiceWorkerRequest& request, const We bServiceWorkerResponse& response) 177 void addRequestResponsePair(const WebServiceWorkerRequest& request, const We bServiceWorkerResponse& response)
178 { 178 {
179 ASSERT(m_numResponsesLeft > 0); 179 ASSERT(m_numResponsesLeft > 0);
180 RequestResponse& requestResponse = m_responses.at(m_responses.size() - m _numResponsesLeft); 180 RequestResponse& requestResponse = m_responses.at(m_responses.size() - m _numResponsesLeft);
181 requestResponse.request = request.url().string(); 181 requestResponse.request = request.url().string();
182 requestResponse.response = response.statusText(); 182 requestResponse.response = response.statusText();
183 183
184 if (--m_numResponsesLeft != 0) 184 if (--m_numResponsesLeft != 0)
185 return; 185 return;
186 186
187 std::sort(m_responses.begin(), m_responses.end(), 187 std::sort(m_responses.begin(), m_responses.end(),
188 [](const RequestResponse& a, const RequestResponse& b) 188 [](const RequestResponse& a, const RequestResponse& b)
189 { 189 {
190 return WTF::codePointCompareLessThan(a.request, b.request); 190 return WTF::codePointCompareLessThan(a.request, b.request);
191 }); 191 });
192 if (m_params.skipCount > 0) 192 if (m_params.skipCount > 0)
193 m_responses.remove(0, m_params.skipCount); 193 m_responses.remove(0, m_params.skipCount);
194 bool hasMore = false; 194 bool hasMore = false;
195 if (static_cast<size_t>(m_params.pageSize) < m_responses.size()) { 195 if (static_cast<size_t>(m_params.pageSize) < m_responses.size()) {
196 m_responses.remove(m_params.pageSize, m_responses.size() - m_params. pageSize); 196 m_responses.remove(m_params.pageSize, m_responses.size() - m_params. pageSize);
197 hasMore = true; 197 hasMore = true;
198 } 198 }
199 OwnPtr<Array<DataEntry>> array = Array<DataEntry>::create(); 199 std::unique_ptr<Array<DataEntry>> array = Array<DataEntry>::create();
200 for (const auto& requestResponse : m_responses) { 200 for (const auto& requestResponse : m_responses) {
201 OwnPtr<DataEntry> entry = DataEntry::create() 201 std::unique_ptr<DataEntry> entry = DataEntry::create()
202 .setRequest(requestResponse.request) 202 .setRequest(requestResponse.request)
203 .setResponse(requestResponse.response).build(); 203 .setResponse(requestResponse.response).build();
204 array->addItem(std::move(entry)); 204 array->addItem(std::move(entry));
205 } 205 }
206 m_callback->sendSuccess(std::move(array), hasMore); 206 m_callback->sendSuccess(std::move(array), hasMore);
207 } 207 }
208 208
209 void sendFailure(const String& error) 209 void sendFailure(const String& error)
210 { 210 {
211 m_callback->sendFailure(error); 211 m_callback->sendFailure(error);
212 } 212 }
213 213
214 private: 214 private:
215 DataRequestParams m_params; 215 DataRequestParams m_params;
216 int m_numResponsesLeft; 216 int m_numResponsesLeft;
217 Vector<RequestResponse> m_responses; 217 Vector<RequestResponse> m_responses;
218 OwnPtr<RequestEntriesCallback> m_callback; 218 std::unique_ptr<RequestEntriesCallback> m_callback;
219 }; 219 };
220 220
221 class GetCacheResponsesForRequestData : public WebServiceWorkerCache::CacheMatch Callbacks { 221 class GetCacheResponsesForRequestData : public WebServiceWorkerCache::CacheMatch Callbacks {
222 WTF_MAKE_NONCOPYABLE(GetCacheResponsesForRequestData); 222 WTF_MAKE_NONCOPYABLE(GetCacheResponsesForRequestData);
223 223
224 public: 224 public:
225 GetCacheResponsesForRequestData(const DataRequestParams& params, const WebSe rviceWorkerRequest& request, PassRefPtr<ResponsesAccumulator> accum) 225 GetCacheResponsesForRequestData(const DataRequestParams& params, const WebSe rviceWorkerRequest& request, PassRefPtr<ResponsesAccumulator> accum)
226 : m_params(params) 226 : m_params(params)
227 , m_request(request) 227 , m_request(request)
228 , m_accumulator(accum) 228 , m_accumulator(accum)
(...skipping 14 matching lines...) Expand all
243 private: 243 private:
244 DataRequestParams m_params; 244 DataRequestParams m_params;
245 WebServiceWorkerRequest m_request; 245 WebServiceWorkerRequest m_request;
246 RefPtr<ResponsesAccumulator> m_accumulator; 246 RefPtr<ResponsesAccumulator> m_accumulator;
247 }; 247 };
248 248
249 class GetCacheKeysForRequestData : public WebServiceWorkerCache::CacheWithReques tsCallbacks { 249 class GetCacheKeysForRequestData : public WebServiceWorkerCache::CacheWithReques tsCallbacks {
250 WTF_MAKE_NONCOPYABLE(GetCacheKeysForRequestData); 250 WTF_MAKE_NONCOPYABLE(GetCacheKeysForRequestData);
251 251
252 public: 252 public:
253 GetCacheKeysForRequestData(const DataRequestParams& params, PassOwnPtr<WebSe rviceWorkerCache> cache, PassOwnPtr<RequestEntriesCallback> callback) 253 GetCacheKeysForRequestData(const DataRequestParams& params, PassOwnPtr<WebSe rviceWorkerCache> cache, std::unique_ptr<RequestEntriesCallback> callback)
254 : m_params(params) 254 : m_params(params)
255 , m_cache(std::move(cache)) 255 , m_cache(std::move(cache))
256 , m_callback(std::move(callback)) 256 , m_callback(std::move(callback))
257 { 257 {
258 } 258 }
259 ~GetCacheKeysForRequestData() override { } 259 ~GetCacheKeysForRequestData() override { }
260 260
261 WebServiceWorkerCache* cache() { return m_cache.get(); } 261 WebServiceWorkerCache* cache() { return m_cache.get(); }
262 void onSuccess(const WebVector<WebServiceWorkerRequest>& requests) override 262 void onSuccess(const WebVector<WebServiceWorkerRequest>& requests) override
263 { 263 {
264 if (requests.isEmpty()) { 264 if (requests.isEmpty()) {
265 OwnPtr<Array<DataEntry>> array = Array<DataEntry>::create(); 265 std::unique_ptr<Array<DataEntry>> array = Array<DataEntry>::create() ;
266 m_callback->sendSuccess(std::move(array), false); 266 m_callback->sendSuccess(std::move(array), false);
267 return; 267 return;
268 } 268 }
269 RefPtr<ResponsesAccumulator> accumulator = adoptRef(new ResponsesAccumul ator(requests.size(), m_params, std::move(m_callback))); 269 RefPtr<ResponsesAccumulator> accumulator = adoptRef(new ResponsesAccumul ator(requests.size(), m_params, std::move(m_callback)));
270 270
271 for (size_t i = 0; i < requests.size(); i++) { 271 for (size_t i = 0; i < requests.size(); i++) {
272 const auto& request = requests[i]; 272 const auto& request = requests[i];
273 auto* cacheRequest = new GetCacheResponsesForRequestData(m_params, r equest, accumulator); 273 auto* cacheRequest = new GetCacheResponsesForRequestData(m_params, r equest, accumulator);
274 m_cache->dispatchMatch(cacheRequest, request, WebServiceWorkerCache: :QueryParams()); 274 m_cache->dispatchMatch(cacheRequest, request, WebServiceWorkerCache: :QueryParams());
275 } 275 }
276 } 276 }
277 277
278 void onError(WebServiceWorkerCacheError error) override 278 void onError(WebServiceWorkerCacheError error) override
279 { 279 {
280 m_callback->sendFailure(String::format("Error requesting requests for ca che %s: %s", m_params.cacheName.utf8().data(), serviceWorkerCacheErrorString(err or).data())); 280 m_callback->sendFailure(String::format("Error requesting requests for ca che %s: %s", m_params.cacheName.utf8().data(), serviceWorkerCacheErrorString(err or).data()));
281 } 281 }
282 282
283 private: 283 private:
284 DataRequestParams m_params; 284 DataRequestParams m_params;
285 OwnPtr<WebServiceWorkerCache> m_cache; 285 OwnPtr<WebServiceWorkerCache> m_cache;
286 OwnPtr<RequestEntriesCallback> m_callback; 286 std::unique_ptr<RequestEntriesCallback> m_callback;
287 }; 287 };
288 288
289 class GetCacheForRequestData 289 class GetCacheForRequestData
290 : public WebServiceWorkerCacheStorage::CacheStorageWithCacheCallbacks { 290 : public WebServiceWorkerCacheStorage::CacheStorageWithCacheCallbacks {
291 WTF_MAKE_NONCOPYABLE(GetCacheForRequestData); 291 WTF_MAKE_NONCOPYABLE(GetCacheForRequestData);
292 292
293 public: 293 public:
294 GetCacheForRequestData(const DataRequestParams& params, PassOwnPtr<RequestEn triesCallback> callback) 294 GetCacheForRequestData(const DataRequestParams& params, std::unique_ptr<Requ estEntriesCallback> callback)
295 : m_params(params) 295 : m_params(params)
296 , m_callback(std::move(callback)) 296 , m_callback(std::move(callback))
297 { 297 {
298 } 298 }
299 ~GetCacheForRequestData() override { } 299 ~GetCacheForRequestData() override { }
300 300
301 void onSuccess(std::unique_ptr<WebServiceWorkerCache> cache) override 301 void onSuccess(std::unique_ptr<WebServiceWorkerCache> cache) override
302 { 302 {
303 auto* cacheRequest = new GetCacheKeysForRequestData(m_params, adoptPtr(c ache.release()), std::move(m_callback)); 303 auto* cacheRequest = new GetCacheKeysForRequestData(m_params, adoptPtr(c ache.release()), std::move(m_callback));
304 cacheRequest->cache()->dispatchKeys(cacheRequest, nullptr, WebServiceWor kerCache::QueryParams()); 304 cacheRequest->cache()->dispatchKeys(cacheRequest, nullptr, WebServiceWor kerCache::QueryParams());
305 } 305 }
306 306
307 void onError(WebServiceWorkerCacheError error) override 307 void onError(WebServiceWorkerCacheError error) override
308 { 308 {
309 m_callback->sendFailure(String::format("Error requesting cache %s: %s", m_params.cacheName.utf8().data(), serviceWorkerCacheErrorString(error).data())); 309 m_callback->sendFailure(String::format("Error requesting cache %s: %s", m_params.cacheName.utf8().data(), serviceWorkerCacheErrorString(error).data()));
310 } 310 }
311 311
312 private: 312 private:
313 DataRequestParams m_params; 313 DataRequestParams m_params;
314 OwnPtr<RequestEntriesCallback> m_callback; 314 std::unique_ptr<RequestEntriesCallback> m_callback;
315 }; 315 };
316 316
317 class DeleteCache : public WebServiceWorkerCacheStorage::CacheStorageCallbacks { 317 class DeleteCache : public WebServiceWorkerCacheStorage::CacheStorageCallbacks {
318 WTF_MAKE_NONCOPYABLE(DeleteCache); 318 WTF_MAKE_NONCOPYABLE(DeleteCache);
319 319
320 public: 320 public:
321 DeleteCache(PassOwnPtr<DeleteCacheCallback> callback) 321 DeleteCache(std::unique_ptr<DeleteCacheCallback> callback)
322 : m_callback(std::move(callback)) 322 : m_callback(std::move(callback))
323 { 323 {
324 } 324 }
325 ~DeleteCache() override { } 325 ~DeleteCache() override { }
326 326
327 void onSuccess() override 327 void onSuccess() override
328 { 328 {
329 m_callback->sendSuccess(); 329 m_callback->sendSuccess();
330 } 330 }
331 331
332 void onError(WebServiceWorkerCacheError error) override 332 void onError(WebServiceWorkerCacheError error) override
333 { 333 {
334 m_callback->sendFailure(String::format("Error requesting cache names: %s ", serviceWorkerCacheErrorString(error).data())); 334 m_callback->sendFailure(String::format("Error requesting cache names: %s ", serviceWorkerCacheErrorString(error).data()));
335 } 335 }
336 336
337 private: 337 private:
338 OwnPtr<DeleteCacheCallback> m_callback; 338 std::unique_ptr<DeleteCacheCallback> m_callback;
339 }; 339 };
340 340
341 class DeleteCacheEntry : public WebServiceWorkerCache::CacheBatchCallbacks { 341 class DeleteCacheEntry : public WebServiceWorkerCache::CacheBatchCallbacks {
342 WTF_MAKE_NONCOPYABLE(DeleteCacheEntry); 342 WTF_MAKE_NONCOPYABLE(DeleteCacheEntry);
343 public: 343 public:
344 344
345 DeleteCacheEntry(PassOwnPtr<DeleteEntryCallback> callback) 345 DeleteCacheEntry(std::unique_ptr<DeleteEntryCallback> callback)
346 : m_callback(std::move(callback)) 346 : m_callback(std::move(callback))
347 { 347 {
348 } 348 }
349 ~DeleteCacheEntry() override { } 349 ~DeleteCacheEntry() override { }
350 350
351 void onSuccess() override 351 void onSuccess() override
352 { 352 {
353 m_callback->sendSuccess(); 353 m_callback->sendSuccess();
354 } 354 }
355 355
356 void onError(WebServiceWorkerCacheError error) override 356 void onError(WebServiceWorkerCacheError error) override
357 { 357 {
358 m_callback->sendFailure(String::format("Error requesting cache names: %s ", serviceWorkerCacheErrorString(error).data())); 358 m_callback->sendFailure(String::format("Error requesting cache names: %s ", serviceWorkerCacheErrorString(error).data()));
359 } 359 }
360 360
361 private: 361 private:
362 OwnPtr<DeleteEntryCallback> m_callback; 362 std::unique_ptr<DeleteEntryCallback> m_callback;
363 }; 363 };
364 364
365 class GetCacheForDeleteEntry 365 class GetCacheForDeleteEntry
366 : public WebServiceWorkerCacheStorage::CacheStorageWithCacheCallbacks { 366 : public WebServiceWorkerCacheStorage::CacheStorageWithCacheCallbacks {
367 WTF_MAKE_NONCOPYABLE(GetCacheForDeleteEntry); 367 WTF_MAKE_NONCOPYABLE(GetCacheForDeleteEntry);
368 368
369 public: 369 public:
370 GetCacheForDeleteEntry(const String& requestSpec, const String& cacheName, P assOwnPtr<DeleteEntryCallback> callback) 370 GetCacheForDeleteEntry(const String& requestSpec, const String& cacheName, s td::unique_ptr<DeleteEntryCallback> callback)
371 : m_requestSpec(requestSpec) 371 : m_requestSpec(requestSpec)
372 , m_cacheName(cacheName) 372 , m_cacheName(cacheName)
373 , m_callback(std::move(callback)) 373 , m_callback(std::move(callback))
374 { 374 {
375 } 375 }
376 ~GetCacheForDeleteEntry() override { } 376 ~GetCacheForDeleteEntry() override { }
377 377
378 void onSuccess(std::unique_ptr<WebServiceWorkerCache> cache) override 378 void onSuccess(std::unique_ptr<WebServiceWorkerCache> cache) override
379 { 379 {
380 auto* deleteRequest = new DeleteCacheEntry(std::move(m_callback)); 380 auto* deleteRequest = new DeleteCacheEntry(std::move(m_callback));
381 BatchOperation deleteOperation; 381 BatchOperation deleteOperation;
382 deleteOperation.operationType = WebServiceWorkerCache::OperationTypeDele te; 382 deleteOperation.operationType = WebServiceWorkerCache::OperationTypeDele te;
383 deleteOperation.request.setURL(KURL(ParsedURLString, m_requestSpec)); 383 deleteOperation.request.setURL(KURL(ParsedURLString, m_requestSpec));
384 Vector<BatchOperation> operations; 384 Vector<BatchOperation> operations;
385 operations.append(deleteOperation); 385 operations.append(deleteOperation);
386 cache.release()->dispatchBatch(deleteRequest, WebVector<BatchOperation>( operations)); 386 cache.release()->dispatchBatch(deleteRequest, WebVector<BatchOperation>( operations));
387 } 387 }
388 388
389 void onError(WebServiceWorkerCacheError error) override 389 void onError(WebServiceWorkerCacheError error) override
390 { 390 {
391 m_callback->sendFailure(String::format("Error requesting cache %s: %s", m_cacheName.utf8().data(), serviceWorkerCacheErrorString(error).data())); 391 m_callback->sendFailure(String::format("Error requesting cache %s: %s", m_cacheName.utf8().data(), serviceWorkerCacheErrorString(error).data()));
392 } 392 }
393 393
394 private: 394 private:
395 String m_requestSpec; 395 String m_requestSpec;
396 String m_cacheName; 396 String m_cacheName;
397 OwnPtr<DeleteEntryCallback> m_callback; 397 std::unique_ptr<DeleteEntryCallback> m_callback;
398 }; 398 };
399 399
400 } // namespace 400 } // namespace
401 401
402 InspectorCacheStorageAgent::InspectorCacheStorageAgent() 402 InspectorCacheStorageAgent::InspectorCacheStorageAgent()
403 : InspectorBaseAgent<InspectorCacheStorageAgent, protocol::Frontend::CacheSt orage>("CacheStorage") 403 : InspectorBaseAgent<InspectorCacheStorageAgent, protocol::Frontend::CacheSt orage>("CacheStorage")
404 { 404 {
405 } 405 }
406 406
407 InspectorCacheStorageAgent::~InspectorCacheStorageAgent() { } 407 InspectorCacheStorageAgent::~InspectorCacheStorageAgent() { }
408 408
409 DEFINE_TRACE(InspectorCacheStorageAgent) 409 DEFINE_TRACE(InspectorCacheStorageAgent)
410 { 410 {
411 InspectorBaseAgent::trace(visitor); 411 InspectorBaseAgent::trace(visitor);
412 } 412 }
413 413
414 void InspectorCacheStorageAgent::requestCacheNames(ErrorString* errorString, con st String& securityOrigin, PassOwnPtr<RequestCacheNamesCallback> callback) 414 void InspectorCacheStorageAgent::requestCacheNames(ErrorString* errorString, con st String& securityOrigin, std::unique_ptr<RequestCacheNamesCallback> callback)
415 { 415 {
416 RefPtr<SecurityOrigin> secOrigin = SecurityOrigin::createFromString(security Origin); 416 RefPtr<SecurityOrigin> secOrigin = SecurityOrigin::createFromString(security Origin);
417 417
418 // Cache Storage API is restricted to trustworthy origins. 418 // Cache Storage API is restricted to trustworthy origins.
419 if (!secOrigin->isPotentiallyTrustworthy()) { 419 if (!secOrigin->isPotentiallyTrustworthy()) {
420 // Don't treat this as an error, just don't attempt to open and enumerat e the caches. 420 // Don't treat this as an error, just don't attempt to open and enumerat e the caches.
421 callback->sendSuccess(Array<protocol::CacheStorage::Cache>::create()); 421 callback->sendSuccess(Array<protocol::CacheStorage::Cache>::create());
422 return; 422 return;
423 } 423 }
424 424
425 OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorage(errorString, securityOrigin); 425 OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorage(errorString, securityOrigin);
426 if (!cache) { 426 if (!cache) {
427 callback->sendFailure(*errorString); 427 callback->sendFailure(*errorString);
428 return; 428 return;
429 } 429 }
430 cache->dispatchKeys(new RequestCacheNames(securityOrigin, std::move(callback ))); 430 cache->dispatchKeys(new RequestCacheNames(securityOrigin, std::move(callback )));
431 } 431 }
432 432
433 void InspectorCacheStorageAgent::requestEntries(ErrorString* errorString, const String& cacheId, int skipCount, int pageSize, PassOwnPtr<RequestEntriesCallback> callback) 433 void InspectorCacheStorageAgent::requestEntries(ErrorString* errorString, const String& cacheId, int skipCount, int pageSize, std::unique_ptr<RequestEntriesCall back> callback)
434 { 434 {
435 String cacheName; 435 String cacheName;
436 OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorageAndNameForId( errorString, cacheId, &cacheName); 436 OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorageAndNameForId( errorString, cacheId, &cacheName);
437 if (!cache) { 437 if (!cache) {
438 callback->sendFailure(*errorString); 438 callback->sendFailure(*errorString);
439 return; 439 return;
440 } 440 }
441 DataRequestParams params; 441 DataRequestParams params;
442 params.cacheName = cacheName; 442 params.cacheName = cacheName;
443 params.pageSize = pageSize; 443 params.pageSize = pageSize;
444 params.skipCount = skipCount; 444 params.skipCount = skipCount;
445 cache->dispatchOpen(new GetCacheForRequestData(params, std::move(callback)), WebString(cacheName)); 445 cache->dispatchOpen(new GetCacheForRequestData(params, std::move(callback)), WebString(cacheName));
446 } 446 }
447 447
448 void InspectorCacheStorageAgent::deleteCache(ErrorString* errorString, const Str ing& cacheId, PassOwnPtr<DeleteCacheCallback> callback) 448 void InspectorCacheStorageAgent::deleteCache(ErrorString* errorString, const Str ing& cacheId, std::unique_ptr<DeleteCacheCallback> callback)
449 { 449 {
450 String cacheName; 450 String cacheName;
451 OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorageAndNameForId( errorString, cacheId, &cacheName); 451 OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorageAndNameForId( errorString, cacheId, &cacheName);
452 if (!cache) { 452 if (!cache) {
453 callback->sendFailure(*errorString); 453 callback->sendFailure(*errorString);
454 return; 454 return;
455 } 455 }
456 cache->dispatchDelete(new DeleteCache(std::move(callback)), WebString(cacheN ame)); 456 cache->dispatchDelete(new DeleteCache(std::move(callback)), WebString(cacheN ame));
457 } 457 }
458 458
459 void InspectorCacheStorageAgent::deleteEntry(ErrorString* errorString, const Str ing& cacheId, const String& request, PassOwnPtr<DeleteEntryCallback> callback) 459 void InspectorCacheStorageAgent::deleteEntry(ErrorString* errorString, const Str ing& cacheId, const String& request, std::unique_ptr<DeleteEntryCallback> callba ck)
460 { 460 {
461 String cacheName; 461 String cacheName;
462 OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorageAndNameForId( errorString, cacheId, &cacheName); 462 OwnPtr<WebServiceWorkerCacheStorage> cache = assertCacheStorageAndNameForId( errorString, cacheId, &cacheName);
463 if (!cache) { 463 if (!cache) {
464 callback->sendFailure(*errorString); 464 callback->sendFailure(*errorString);
465 return; 465 return;
466 } 466 }
467 cache->dispatchOpen(new GetCacheForDeleteEntry(request, cacheName, std::move (callback)), WebString(cacheName)); 467 cache->dispatchOpen(new GetCacheForDeleteEntry(request, cacheName, std::move (callback)), WebString(cacheName));
468 } 468 }
469 469
470 470
471 } // namespace blink 471 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698