| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 | 10 |
| 11 #if defined(OS_POSIX) | 11 #if defined(OS_POSIX) |
| 12 #include <unistd.h> | 12 #include <unistd.h> |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 #include "base/callback.h" | 15 #include "base/callback.h" |
| 16 #include "base/format_macros.h" | 16 #include "base/format_macros.h" |
| 17 #include "base/message_loop.h" | 17 #include "base/message_loop.h" |
| 18 #include "base/pickle.h" | 18 #include "base/pickle.h" |
| 19 #include "base/ref_counted.h" | 19 #include "base/ref_counted.h" |
| 20 #include "base/stl_util-inl.h" | 20 #include "base/stl_util-inl.h" |
| 21 #include "base/string_number_conversions.h" |
| 21 #include "base/string_util.h" | 22 #include "base/string_util.h" |
| 22 #include "base/string_number_conversions.h" | 23 #include "base/stringprintf.h" |
| 23 #include "net/base/io_buffer.h" | 24 #include "net/base/io_buffer.h" |
| 24 #include "net/base/load_flags.h" | 25 #include "net/base/load_flags.h" |
| 25 #include "net/base/net_errors.h" | 26 #include "net/base/net_errors.h" |
| 26 #include "net/disk_cache/disk_cache.h" | 27 #include "net/disk_cache/disk_cache.h" |
| 27 #include "net/http/http_cache_transaction.h" | 28 #include "net/http/http_cache_transaction.h" |
| 28 #include "net/http/http_network_layer.h" | 29 #include "net/http/http_network_layer.h" |
| 29 #include "net/http/http_network_session.h" | 30 #include "net/http/http_network_session.h" |
| 30 #include "net/http/http_request_info.h" | 31 #include "net/http/http_request_info.h" |
| 31 #include "net/http/http_response_headers.h" | 32 #include "net/http/http_response_headers.h" |
| 32 #include "net/http/http_response_info.h" | 33 #include "net/http/http_response_info.h" |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 // Generate a key that can be used inside the cache. | 452 // Generate a key that can be used inside the cache. |
| 452 std::string HttpCache::GenerateCacheKey(const HttpRequestInfo* request) { | 453 std::string HttpCache::GenerateCacheKey(const HttpRequestInfo* request) { |
| 453 // Strip out the reference, username, and password sections of the URL. | 454 // Strip out the reference, username, and password sections of the URL. |
| 454 std::string url = HttpUtil::SpecForRequest(request->url); | 455 std::string url = HttpUtil::SpecForRequest(request->url); |
| 455 | 456 |
| 456 DCHECK(mode_ != DISABLE); | 457 DCHECK(mode_ != DISABLE); |
| 457 if (mode_ == NORMAL) { | 458 if (mode_ == NORMAL) { |
| 458 // No valid URL can begin with numerals, so we should not have to worry | 459 // No valid URL can begin with numerals, so we should not have to worry |
| 459 // about collisions with normal URLs. | 460 // about collisions with normal URLs. |
| 460 if (request->upload_data && request->upload_data->identifier()) { | 461 if (request->upload_data && request->upload_data->identifier()) { |
| 461 url.insert(0, StringPrintf("%" PRId64 "/", | 462 url.insert(0, base::StringPrintf("%" PRId64 "/", |
| 462 request->upload_data->identifier())); | 463 request->upload_data->identifier())); |
| 463 } | 464 } |
| 464 return url; | 465 return url; |
| 465 } | 466 } |
| 466 | 467 |
| 467 // In playback and record mode, we cache everything. | 468 // In playback and record mode, we cache everything. |
| 468 | 469 |
| 469 // Lazily initialize. | 470 // Lazily initialize. |
| 470 if (playback_cache_map_ == NULL) | 471 if (playback_cache_map_ == NULL) |
| 471 playback_cache_map_.reset(new PlaybackCacheMap()); | 472 playback_cache_map_.reset(new PlaybackCacheMap()); |
| 472 | 473 |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 building_backend_ = false; | 1053 building_backend_ = false; |
| 1053 DeletePendingOp(pending_op); | 1054 DeletePendingOp(pending_op); |
| 1054 } | 1055 } |
| 1055 | 1056 |
| 1056 // The cache may be gone when we return from the callback. | 1057 // The cache may be gone when we return from the callback. |
| 1057 if (!item->DoCallback(result, backend)) | 1058 if (!item->DoCallback(result, backend)) |
| 1058 item->NotifyTransaction(result, NULL); | 1059 item->NotifyTransaction(result, NULL); |
| 1059 } | 1060 } |
| 1060 | 1061 |
| 1061 } // namespace net | 1062 } // namespace net |
| OLD | NEW |