| 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 <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/format_macros.h" |
| 15 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
| 16 #include "base/pickle.h" | 17 #include "base/pickle.h" |
| 17 #include "base/ref_counted.h" | 18 #include "base/ref_counted.h" |
| 18 #include "base/string_util.h" | 19 #include "base/string_util.h" |
| 19 #include "net/base/io_buffer.h" | 20 #include "net/base/io_buffer.h" |
| 20 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
| 21 #include "net/disk_cache/disk_cache.h" | 22 #include "net/disk_cache/disk_cache.h" |
| 22 #include "net/http/http_cache_transaction.h" | 23 #include "net/http/http_cache_transaction.h" |
| 23 #include "net/http/http_network_layer.h" | 24 #include "net/http/http_network_layer.h" |
| 24 #include "net/http/http_network_session.h" | 25 #include "net/http/http_network_session.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 204 |
| 204 // Generate a key that can be used inside the cache. | 205 // Generate a key that can be used inside the cache. |
| 205 std::string HttpCache::GenerateCacheKey(const HttpRequestInfo* request) { | 206 std::string HttpCache::GenerateCacheKey(const HttpRequestInfo* request) { |
| 206 // Strip out the reference, username, and password sections of the URL. | 207 // Strip out the reference, username, and password sections of the URL. |
| 207 std::string url = HttpUtil::SpecForRequest(request->url); | 208 std::string url = HttpUtil::SpecForRequest(request->url); |
| 208 | 209 |
| 209 DCHECK(mode_ != DISABLE); | 210 DCHECK(mode_ != DISABLE); |
| 210 if (mode_ == NORMAL) { | 211 if (mode_ == NORMAL) { |
| 211 // No valid URL can begin with numerals, so we should not have to worry | 212 // No valid URL can begin with numerals, so we should not have to worry |
| 212 // about collisions with normal URLs. | 213 // about collisions with normal URLs. |
| 213 if (request->upload_data && request->upload_data->identifier()) | 214 if (request->upload_data && request->upload_data->identifier()) { |
| 214 url.insert(0, StringPrintf("%lld/", request->upload_data->identifier())); | 215 url.insert(0, StringPrintf("%" PRId64 "/", |
| 216 request->upload_data->identifier())); |
| 217 } |
| 215 return url; | 218 return url; |
| 216 } | 219 } |
| 217 | 220 |
| 218 // In playback and record mode, we cache everything. | 221 // In playback and record mode, we cache everything. |
| 219 | 222 |
| 220 // Lazily initialize. | 223 // Lazily initialize. |
| 221 if (playback_cache_map_ == NULL) | 224 if (playback_cache_map_ == NULL) |
| 222 playback_cache_map_.reset(new PlaybackCacheMap()); | 225 playback_cache_map_.reset(new PlaybackCacheMap()); |
| 223 | 226 |
| 224 // Each time we request an item from the cache, we tag it with a | 227 // Each time we request an item from the cache, we tag it with a |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 static_cast<net::HttpNetworkLayer*>(network_layer_.get()); | 528 static_cast<net::HttpNetworkLayer*>(network_layer_.get()); |
| 526 HttpNetworkSession* session = network->GetSession(); | 529 HttpNetworkSession* session = network->GetSession(); |
| 527 if (session) { | 530 if (session) { |
| 528 session->tcp_socket_pool()->CloseIdleSockets(); | 531 session->tcp_socket_pool()->CloseIdleSockets(); |
| 529 } | 532 } |
| 530 } | 533 } |
| 531 | 534 |
| 532 //----------------------------------------------------------------------------- | 535 //----------------------------------------------------------------------------- |
| 533 | 536 |
| 534 } // namespace net | 537 } // namespace net |
| OLD | NEW |