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

Side by Side Diff: net/http/http_cache_unittest.cc

Issue 2869005: Disk Cache: Remove deprecated methods from the disk cache interface.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/stress_cache.cc ('k') | net/tools/dump_cache/cache_dumper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2010 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 "net/http/http_cache.h" 5 #include "net/http/http_cache.h"
6 6
7 #include "base/hash_tables.h" 7 #include "base/hash_tables.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/scoped_vector.h" 9 #include "base/scoped_vector.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 data_[1].resize(real_offset + buf_len); 208 data_[1].resize(real_offset + buf_len);
209 209
210 memcpy(&data_[1][real_offset], buf->data(), buf_len); 210 memcpy(&data_[1][real_offset], buf->data(), buf_len);
211 if (GetEffectiveTestMode(test_mode_) & TEST_MODE_SYNC_CACHE_WRITE) 211 if (GetEffectiveTestMode(test_mode_) & TEST_MODE_SYNC_CACHE_WRITE)
212 return buf_len; 212 return buf_len;
213 213
214 CallbackLater(callback, buf_len); 214 CallbackLater(callback, buf_len);
215 return net::ERR_IO_PENDING; 215 return net::ERR_IO_PENDING;
216 } 216 }
217 217
218 virtual int GetAvailableRange(int64 offset, int len, int64* start) {
219 NOTREACHED();
220 return net::ERR_NOT_IMPLEMENTED;
221 }
222
223 virtual int GetAvailableRange(int64 offset, int len, int64* start, 218 virtual int GetAvailableRange(int64 offset, int len, int64* start,
224 net::CompletionCallback* callback) { 219 net::CompletionCallback* callback) {
225 DCHECK(callback); 220 DCHECK(callback);
226 if (!sparse_ || busy_) 221 if (!sparse_ || busy_)
227 return net::ERR_CACHE_OPERATION_NOT_SUPPORTED; 222 return net::ERR_CACHE_OPERATION_NOT_SUPPORTED;
228 if (offset < 0) 223 if (offset < 0)
229 return net::ERR_FAILED; 224 return net::ERR_FAILED;
230 225
231 if (fail_requests_) 226 if (fail_requests_)
232 return net::ERR_CACHE_READ_FAILURE; 227 return net::ERR_CACHE_READ_FAILURE;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 ~MockDiskCache() { 371 ~MockDiskCache() {
377 EntryMap::iterator it = entries_.begin(); 372 EntryMap::iterator it = entries_.begin();
378 for (; it != entries_.end(); ++it) 373 for (; it != entries_.end(); ++it)
379 it->second->Release(); 374 it->second->Release();
380 } 375 }
381 376
382 virtual int32 GetEntryCount() const { 377 virtual int32 GetEntryCount() const {
383 return static_cast<int32>(entries_.size()); 378 return static_cast<int32>(entries_.size());
384 } 379 }
385 380
386 virtual bool OpenEntry(const std::string& key, disk_cache::Entry** entry) {
387 NOTREACHED();
388 return false;
389 }
390
391 virtual int OpenEntry(const std::string& key, disk_cache::Entry** entry, 381 virtual int OpenEntry(const std::string& key, disk_cache::Entry** entry,
392 net::CompletionCallback* callback) { 382 net::CompletionCallback* callback) {
393 DCHECK(callback); 383 DCHECK(callback);
394 if (fail_requests_) 384 if (fail_requests_)
395 return net::ERR_CACHE_OPEN_FAILURE; 385 return net::ERR_CACHE_OPEN_FAILURE;
396 386
397 EntryMap::iterator it = entries_.find(key); 387 EntryMap::iterator it = entries_.find(key);
398 if (it == entries_.end()) 388 if (it == entries_.end())
399 return net::ERR_CACHE_OPEN_FAILURE; 389 return net::ERR_CACHE_OPEN_FAILURE;
400 390
(...skipping 11 matching lines...) Expand all
412 if (soft_failures_) 402 if (soft_failures_)
413 it->second->set_fail_requests(); 403 it->second->set_fail_requests();
414 404
415 if (GetTestModeForEntry(key) & TEST_MODE_SYNC_CACHE_START) 405 if (GetTestModeForEntry(key) & TEST_MODE_SYNC_CACHE_START)
416 return net::OK; 406 return net::OK;
417 407
418 CallbackLater(callback, net::OK); 408 CallbackLater(callback, net::OK);
419 return net::ERR_IO_PENDING; 409 return net::ERR_IO_PENDING;
420 } 410 }
421 411
422 virtual bool CreateEntry(const std::string& key, disk_cache::Entry** entry) {
423 NOTREACHED();
424 return false;
425 }
426
427 virtual int CreateEntry(const std::string& key, disk_cache::Entry** entry, 412 virtual int CreateEntry(const std::string& key, disk_cache::Entry** entry,
428 net::CompletionCallback* callback) { 413 net::CompletionCallback* callback) {
429 DCHECK(callback); 414 DCHECK(callback);
430 if (fail_requests_) 415 if (fail_requests_)
431 return net::ERR_CACHE_CREATE_FAILURE; 416 return net::ERR_CACHE_CREATE_FAILURE;
432 417
433 EntryMap::iterator it = entries_.find(key); 418 EntryMap::iterator it = entries_.find(key);
434 if (it != entries_.end()) { 419 if (it != entries_.end()) {
435 DCHECK(it->second->is_doomed()); 420 DCHECK(it->second->is_doomed());
436 it->second->Release(); 421 it->second->Release();
(...skipping 13 matching lines...) Expand all
450 if (soft_failures_) 435 if (soft_failures_)
451 new_entry->set_fail_requests(); 436 new_entry->set_fail_requests();
452 437
453 if (GetTestModeForEntry(key) & TEST_MODE_SYNC_CACHE_START) 438 if (GetTestModeForEntry(key) & TEST_MODE_SYNC_CACHE_START)
454 return net::OK; 439 return net::OK;
455 440
456 CallbackLater(callback, net::OK); 441 CallbackLater(callback, net::OK);
457 return net::ERR_IO_PENDING; 442 return net::ERR_IO_PENDING;
458 } 443 }
459 444
460 virtual bool DoomEntry(const std::string& key) {
461 NOTREACHED();
462 return false;
463 }
464
465 virtual int DoomEntry(const std::string& key, 445 virtual int DoomEntry(const std::string& key,
466 net::CompletionCallback* callback) { 446 net::CompletionCallback* callback) {
467 DCHECK(callback); 447 DCHECK(callback);
468 EntryMap::iterator it = entries_.find(key); 448 EntryMap::iterator it = entries_.find(key);
469 if (it != entries_.end()) { 449 if (it != entries_.end()) {
470 it->second->Release(); 450 it->second->Release();
471 entries_.erase(it); 451 entries_.erase(it);
472 } 452 }
473 453
474 if (GetTestModeForEntry(key) & TEST_MODE_SYNC_CACHE_START) 454 if (GetTestModeForEntry(key) & TEST_MODE_SYNC_CACHE_START)
475 return net::OK; 455 return net::OK;
476 456
477 CallbackLater(callback, net::OK); 457 CallbackLater(callback, net::OK);
478 return net::ERR_IO_PENDING; 458 return net::ERR_IO_PENDING;
479 } 459 }
480 460
481 virtual bool DoomAllEntries() {
482 NOTREACHED();
483 return false;
484 }
485
486 virtual int DoomAllEntries(net::CompletionCallback* callback) { 461 virtual int DoomAllEntries(net::CompletionCallback* callback) {
487 return net::ERR_NOT_IMPLEMENTED; 462 return net::ERR_NOT_IMPLEMENTED;
488 } 463 }
489 464
490 virtual bool DoomEntriesBetween(const Time initial_time,
491 const Time end_time) {
492 NOTREACHED();
493 return false;
494 }
495
496 virtual int DoomEntriesBetween(const base::Time initial_time, 465 virtual int DoomEntriesBetween(const base::Time initial_time,
497 const base::Time end_time, 466 const base::Time end_time,
498 net::CompletionCallback* callback) { 467 net::CompletionCallback* callback) {
499 return net::ERR_NOT_IMPLEMENTED; 468 return net::ERR_NOT_IMPLEMENTED;
500 } 469 }
501 470
502 virtual bool DoomEntriesSince(const Time initial_time) {
503 NOTREACHED();
504 return false;
505 }
506
507 virtual int DoomEntriesSince(const base::Time initial_time, 471 virtual int DoomEntriesSince(const base::Time initial_time,
508 net::CompletionCallback* callback) { 472 net::CompletionCallback* callback) {
509 return net::ERR_NOT_IMPLEMENTED; 473 return net::ERR_NOT_IMPLEMENTED;
510 } 474 }
511 475
512 virtual bool OpenNextEntry(void** iter, disk_cache::Entry** next_entry) {
513 NOTREACHED();
514 return false;
515 }
516
517 virtual int OpenNextEntry(void** iter, disk_cache::Entry** next_entry, 476 virtual int OpenNextEntry(void** iter, disk_cache::Entry** next_entry,
518 net::CompletionCallback* callback) { 477 net::CompletionCallback* callback) {
519 return net::ERR_NOT_IMPLEMENTED; 478 return net::ERR_NOT_IMPLEMENTED;
520 } 479 }
521 480
522 virtual void EndEnumeration(void** iter) {} 481 virtual void EndEnumeration(void** iter) {}
523 482
524 virtual void GetStats( 483 virtual void GetStats(
525 std::vector<std::pair<std::string, std::string> >* stats) { 484 std::vector<std::pair<std::string, std::string> >* stats) {
526 } 485 }
(...skipping 4109 matching lines...) Expand 10 before | Expand all | Expand 10 after
4636 // Now return 200 when validating the entry so the metadata will be lost. 4595 // Now return 200 when validating the entry so the metadata will be lost.
4637 MockTransaction trans2(kTypicalGET_Transaction); 4596 MockTransaction trans2(kTypicalGET_Transaction);
4638 trans2.load_flags = net::LOAD_VALIDATE_CACHE; 4597 trans2.load_flags = net::LOAD_VALIDATE_CACHE;
4639 RunTransactionTestWithResponseInfo(cache.http_cache(), trans2, &response); 4598 RunTransactionTestWithResponseInfo(cache.http_cache(), trans2, &response);
4640 EXPECT_TRUE(response.metadata.get() == NULL); 4599 EXPECT_TRUE(response.metadata.get() == NULL);
4641 4600
4642 EXPECT_EQ(3, cache.network_layer()->transaction_count()); 4601 EXPECT_EQ(3, cache.network_layer()->transaction_count());
4643 EXPECT_EQ(4, cache.disk_cache()->open_count()); 4602 EXPECT_EQ(4, cache.disk_cache()->open_count());
4644 EXPECT_EQ(1, cache.disk_cache()->create_count()); 4603 EXPECT_EQ(1, cache.disk_cache()->create_count());
4645 } 4604 }
OLDNEW
« no previous file with comments | « net/disk_cache/stress_cache.cc ('k') | net/tools/dump_cache/cache_dumper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698