| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 221 } |
| 222 } else { | 222 } else { |
| 223 if (!data_[1][real_offset]) | 223 if (!data_[1][real_offset]) |
| 224 break; | 224 break; |
| 225 count++; | 225 count++; |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 return count; | 228 return count; |
| 229 } | 229 } |
| 230 | 230 |
| 231 virtual int GetAvailableRange(int64 offset, int len, int64* start, |
| 232 net::CompletionCallback* callback) { |
| 233 return net::ERR_NOT_IMPLEMENTED; |
| 234 } |
| 235 |
| 231 virtual void CancelSparseIO() { cancel_ = true; } | 236 virtual void CancelSparseIO() { cancel_ = true; } |
| 232 | 237 |
| 233 virtual int ReadyForSparseIO(net::CompletionCallback* completion_callback) { | 238 virtual int ReadyForSparseIO(net::CompletionCallback* completion_callback) { |
| 234 if (!cancel_) | 239 if (!cancel_) |
| 235 return net::OK; | 240 return net::OK; |
| 236 | 241 |
| 237 cancel_ = false; | 242 cancel_ = false; |
| 238 DCHECK(completion_callback); | 243 DCHECK(completion_callback); |
| 239 if (test_mode_ & TEST_MODE_SYNC_CACHE_READ) | 244 if (test_mode_ & TEST_MODE_SYNC_CACHE_READ) |
| 240 return net::OK; | 245 return net::OK; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 | 329 |
| 325 it->second->AddRef(); | 330 it->second->AddRef(); |
| 326 *entry = it->second; | 331 *entry = it->second; |
| 327 | 332 |
| 328 if (soft_failures_) | 333 if (soft_failures_) |
| 329 it->second->set_fail_requests(); | 334 it->second->set_fail_requests(); |
| 330 | 335 |
| 331 return true; | 336 return true; |
| 332 } | 337 } |
| 333 | 338 |
| 339 virtual int OpenEntry(const std::string& key, disk_cache::Entry** entry, |
| 340 net::CompletionCallback* callback) { |
| 341 return net::ERR_NOT_IMPLEMENTED; |
| 342 } |
| 343 |
| 334 virtual bool CreateEntry(const std::string& key, disk_cache::Entry** entry) { | 344 virtual bool CreateEntry(const std::string& key, disk_cache::Entry** entry) { |
| 335 if (fail_requests_) | 345 if (fail_requests_) |
| 336 return false; | 346 return false; |
| 337 | 347 |
| 338 EntryMap::iterator it = entries_.find(key); | 348 EntryMap::iterator it = entries_.find(key); |
| 339 DCHECK(it == entries_.end()); | 349 DCHECK(it == entries_.end()); |
| 340 | 350 |
| 341 create_count_++; | 351 create_count_++; |
| 342 | 352 |
| 343 MockDiskEntry* new_entry = new MockDiskEntry(key); | 353 MockDiskEntry* new_entry = new MockDiskEntry(key); |
| 344 | 354 |
| 345 new_entry->AddRef(); | 355 new_entry->AddRef(); |
| 346 entries_[key] = new_entry; | 356 entries_[key] = new_entry; |
| 347 | 357 |
| 348 new_entry->AddRef(); | 358 new_entry->AddRef(); |
| 349 *entry = new_entry; | 359 *entry = new_entry; |
| 350 | 360 |
| 351 if (soft_failures_) | 361 if (soft_failures_) |
| 352 new_entry->set_fail_requests(); | 362 new_entry->set_fail_requests(); |
| 353 | 363 |
| 354 return true; | 364 return true; |
| 355 } | 365 } |
| 356 | 366 |
| 367 virtual int CreateEntry(const std::string& key, disk_cache::Entry** entry, |
| 368 net::CompletionCallback* callback) { |
| 369 return net::ERR_NOT_IMPLEMENTED; |
| 370 } |
| 371 |
| 357 virtual bool DoomEntry(const std::string& key) { | 372 virtual bool DoomEntry(const std::string& key) { |
| 358 EntryMap::iterator it = entries_.find(key); | 373 EntryMap::iterator it = entries_.find(key); |
| 359 if (it != entries_.end()) { | 374 if (it != entries_.end()) { |
| 360 it->second->Release(); | 375 it->second->Release(); |
| 361 entries_.erase(it); | 376 entries_.erase(it); |
| 362 } | 377 } |
| 363 return true; | 378 return true; |
| 364 } | 379 } |
| 365 | 380 |
| 366 virtual bool DoomAllEntries() { | 381 virtual bool DoomAllEntries() { |
| 367 return false; | 382 return false; |
| 368 } | 383 } |
| 369 | 384 |
| 385 virtual int DoomAllEntries(net::CompletionCallback* callback) { |
| 386 return net::ERR_NOT_IMPLEMENTED; |
| 387 } |
| 388 |
| 370 virtual bool DoomEntriesBetween(const Time initial_time, | 389 virtual bool DoomEntriesBetween(const Time initial_time, |
| 371 const Time end_time) { | 390 const Time end_time) { |
| 372 return true; | 391 return true; |
| 373 } | 392 } |
| 374 | 393 |
| 394 virtual int DoomEntriesBetween(const base::Time initial_time, |
| 395 const base::Time end_time, |
| 396 net::CompletionCallback* callback) { |
| 397 return net::ERR_NOT_IMPLEMENTED; |
| 398 } |
| 399 |
| 375 virtual bool DoomEntriesSince(const Time initial_time) { | 400 virtual bool DoomEntriesSince(const Time initial_time) { |
| 376 return true; | 401 return true; |
| 377 } | 402 } |
| 378 | 403 |
| 404 virtual int DoomEntriesSince(const base::Time initial_time, |
| 405 net::CompletionCallback* callback) { |
| 406 return net::ERR_NOT_IMPLEMENTED; |
| 407 } |
| 408 |
| 379 virtual bool OpenNextEntry(void** iter, disk_cache::Entry** next_entry) { | 409 virtual bool OpenNextEntry(void** iter, disk_cache::Entry** next_entry) { |
| 380 return false; | 410 return false; |
| 381 } | 411 } |
| 382 | 412 |
| 413 virtual int OpenNextEntry(void** iter, disk_cache::Entry** next_entry, |
| 414 net::CompletionCallback* callback) { |
| 415 return net::ERR_NOT_IMPLEMENTED; |
| 416 } |
| 417 |
| 383 virtual void EndEnumeration(void** iter) {} | 418 virtual void EndEnumeration(void** iter) {} |
| 384 | 419 |
| 385 virtual void GetStats( | 420 virtual void GetStats( |
| 386 std::vector<std::pair<std::string, std::string> >* stats) { | 421 std::vector<std::pair<std::string, std::string> >* stats) { |
| 387 } | 422 } |
| 388 | 423 |
| 389 // returns number of times a cache entry was successfully opened | 424 // returns number of times a cache entry was successfully opened |
| 390 int open_count() const { return open_count_; } | 425 int open_count() const { return open_count_; } |
| 391 | 426 |
| 392 // returns number of times a cache entry was successfully created | 427 // returns number of times a cache entry was successfully created |
| (...skipping 3017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3410 std::string headers; | 3445 std::string headers; |
| 3411 response.headers->GetNormalizedHeaders(&headers); | 3446 response.headers->GetNormalizedHeaders(&headers); |
| 3412 | 3447 |
| 3413 EXPECT_EQ("HTTP/1.1 200 OK\n" | 3448 EXPECT_EQ("HTTP/1.1 200 OK\n" |
| 3414 "Date: Wed, 22 Jul 2009 03:15:26 GMT\n" | 3449 "Date: Wed, 22 Jul 2009 03:15:26 GMT\n" |
| 3415 "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n", | 3450 "Last-Modified: Wed, 06 Feb 2008 22:38:21 GMT\n", |
| 3416 headers); | 3451 headers); |
| 3417 | 3452 |
| 3418 RemoveMockTransaction(&mock_network_response); | 3453 RemoveMockTransaction(&mock_network_response); |
| 3419 } | 3454 } |
| OLD | NEW |