summaryrefslogtreecommitdiffstats
path: root/net/http/http_cache_unittest.cc
Commit message (Collapse)AuthorAgeFilesLines
* Http cache: Unit test for cl 33919rvargas@google.com2009-12-071-0/+10
| | | | | | | | | BUG=25859 TEST=unittests Review URL: http://codereview.chromium.org/465087 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33999 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Don't access entry_ if an error switchesrvargas@google.com2009-12-021-0/+37
| | | | | | | | | | | | the transaction to mode NONE and deletes the entry_. BUG=28994 TEST=unittests Review URL: http://codereview.chromium.org/449069 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33580 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Add code to restart a network request when thervargas@google.com2009-12-011-0/+42
| | | | | | | | | | | | server doesn't revalidate a partially stored entry, in other words, after we issued a conditional byte range request. BUG=27276, 28850 TEST=unittests Review URL: http://codereview.chromium.org/452017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33412 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 33133 - Http cache: Add code to restart a network request when thervargas@google.com2009-11-301-42/+0
| | | | | | | | | | | | | | | server doesn't revalidate a partially stored entry, in other words, after we issued a conditional byte range request. BUG=27276, 28850 TEST=unittests Review URL: http://codereview.chromium.org/434052 TBR=rvargas@google.com Review URL: http://codereview.chromium.org/452003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33253 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Add code to restart a network request when thervargas@google.com2009-11-251-0/+42
| | | | | | | | | | | | server doesn't revalidate a partially stored entry, in other words, after we issued a conditional byte range request. BUG=27276 TEST=unittests Review URL: http://codereview.chromium.org/434052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33133 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Make sure that when we cancel a request forrvargas@google.com2009-11-201-0/+67
| | | | | | | | | | | | | a truncated entry, we keep the truncation flag. BUG=27276 TEST=unittests Review URL: http://codereview.chromium.org/422002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32707 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Add the logic to cancel entry_ready_callback_.rvargas@google.com2009-11-191-1/+101
| | | | | | | | | BUG=28204 TEST=unittests Review URL: http://codereview.chromium.org/403027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32523 0039d316-1c4b-4281-b951-d872f2087c98
* Clear disk cache when the cache is not initializedhclam@chromium.org2009-11-071-1/+11
| | | | | | | | | | | | | | BUG=24765 TEST=unit test, clear browsing data and the cache, media cache will be cleared even if a media object was not loaded. Since the disk cache backend in HttpCache is lazily initialized, clearing the cache before it receives the first transaction would have no effect. So initialize the disk cache explicitly when we clear the cache. Review URL: http://codereview.chromium.org/378015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31361 0039d316-1c4b-4281-b951-d872f2087c98
* Improve the display of LoadLogs when truncation occurs.eroman@chromium.org2009-11-061-3/+3
| | | | | | | | | | | | | | Rather than drop all subsequent entries, we now preserve the final entry that was appended to the log. This way, even if entries have been dropped, we can still infer what the total time was, and what the exit condition was. Also makes LoadLog take the bound as a required parameter. BUG=none TEST=LoadLogUtilTest.DisplayOfTruncated Review URL: http://codereview.chromium.org/363025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31274 0039d316-1c4b-4281-b951-d872f2087c98
* Second patch in making destructors of refcounted objects private.jam@chromium.org2009-11-051-3/+4
| | | | | | | | BUG=26749 Review URL: http://codereview.chromium.org/368001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31165 0039d316-1c4b-4281-b951-d872f2087c98
* Disk Cache: New interface that enables asynchronous completionrvargas@google.com2009-11-051-0/+35
| | | | | | | | | | | of any operation that may block. BUG=26730 TEST=none Review URL: http://codereview.chromium.org/355028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31160 0039d316-1c4b-4281-b951-d872f2087c98
* HTTP cache: Add tests to verify that we don't remove thervargas@google.com2009-11-051-5/+50
| | | | | | | | | | | | request headers for simple and externally conditionalized requests. BUG=NONE TEST=unittests Review URL: http://codereview.chromium.org/361022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31108 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Make sure that we handle byte range requests thatrvargas@google.com2009-11-031-0/+22
| | | | | | | | | | | | end up skipping the cache. BUG=26175 TEST=unittests Review URL: http://codereview.chromium.org/348053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30877 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Always preserve extra headers when dealing withrvargas@google.com2009-11-031-17/+32
| | | | | | | | | | | byte range requests. BUG=25755 TEST=unittests Review URL: http://codereview.chromium.org/339088 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30773 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Allow multiple external validation headers.rvargas@google.com2009-11-021-0/+115
| | | | | | | | | | | | If the last pair of headers match the entry that we have we allow the server response to update the entry. BUG=23222 TEST=unittests Review URL: http://codereview.chromium.org/345019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30748 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Handle byte range requests when there is no cache entry.rvargas@google.com2009-10-271-0/+13
| | | | | | | | | | BUG=25873 TEST=unittest Review URL: http://codereview.chromium.org/330026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30165 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Make sure that we remove pending transactionsrvargas@google.com2009-10-261-0/+50
| | | | | | | | | | | when they belong to a doomed entry. BUG=25588 TEST=unittests Review URL: http://codereview.chromium.org/335015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30054 0039d316-1c4b-4281-b951-d872f2087c98
* Http Cache: Convert data writes from sysnchronous to asynchronous.rvargas@google.com2009-10-221-13/+61
| | | | | | | | | | BUG=21383 TEST=unit tests (original review for r25873: http://codereview.chromium.org/201065) Review URL: http://codereview.chromium.org/313013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29792 0039d316-1c4b-4281-b951-d872f2087c98
* Http Cache: More unit tests for byte range support.rvargas@google.com2009-10-141-0/+140
| | | | | | | | | BUG=b/2071330 TEST=unittests Review URL: http://codereview.chromium.org/267101 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29035 0039d316-1c4b-4281-b951-d872f2087c98
* Disk cache: Add a method to cancel pending sparse operations.rvargas@google.com2009-10-081-4/+94
| | | | | | | | | | | | | | | | | | | The sparse IO methods require exclusive use of the cache entry and they complain when that requirement is violated. When the user cancels a request and reissues another one to the same entry, we may be waiting for the previous operation to finish when we receive a new IO request, so we fail. This CL add a way for the HTTP cache to cancel IO operations and get a notification when the disk cache is able to operate on that entry again. BUG=23862 TEST=unittests Review URL: http://codereview.chromium.org/256090 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28475 0039d316-1c4b-4281-b951-d872f2087c98
* Handle range request on a truncated entryhclam@chromium.org2009-10-021-0/+44
| | | | | | | | | | This change will doom the truncated entry and creates a new sparse entry. TEST=unit tests Review URL: http://codereview.chromium.org/251067 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27859 0039d316-1c4b-4281-b951-d872f2087c98
* Handle reading to the end of a sparse entryhclam@chromium.org2009-10-011-0/+3
| | | | | | | | | | | | TEST=run chrome with --enable-byte-range-support --incognito and watch a video in http://tinyvid.tv/, seeking should be fine. http_cache::PartialData used to read a length of zero when reading has reached the end. The zero parameter will cause MemEntryImpl to complain about invalid argument, so early return for the case that we know we have nothing to read. Review URL: http://codereview.chromium.org/255034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27776 0039d316-1c4b-4281-b951-d872f2087c98
* Remove a redefined variable.eroman@chromium.org2009-09-241-1/+1
| | | | | | | | | | This got introduced with my changes to http_cache_unittest.cc. TBR=wtc Review URL: http://codereview.chromium.org/231011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27039 0039d316-1c4b-4281-b951-d872f2087c98
* Replace some net::ERR_FAILED generic error codes with more specific codes.eroman@chromium.org2009-09-241-58/+76
| | | | | | | | | | The goal is to end up with more meaningful errors if a page fails to load. BUG=22623 Review URL: http://codereview.chromium.org/222009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27038 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 25873.eroman@chromium.org2009-09-221-15/+4
| | | | | | | | | | | This appears to be responsible for a regression in downloading of files. BUG=http://crbug.com/406 TBR=darin Review URL: http://codereview.chromium.org/215035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26764 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Convert data writes from sysnchronous to asynchronous.rvargas@google.com2009-09-101-4/+15
| | | | | | | | | | BUG=21383 TEST=covered by current unit tests. Review URL: http://codereview.chromium.org/201065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25873 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Don't delete sparse entries when wervargas@google.com2009-09-091-0/+36
| | | | | | | | | | | cancel the request. BUG=20930 TEST=unittests Review URL: http://codereview.chromium.org/193043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25736 0039d316-1c4b-4281-b951-d872f2087c98
* Add some trace-points to HttpCache for request profiling (cache entry ↵eroman@chromium.org2009-09-061-10/+74
| | | | | | | | | | | "open", "create", "waiting" and "read_info"). BUG=http://crbug.com/14478 TEST=HttpCache unittests. Review URL: http://codereview.chromium.org/201035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25583 0039d316-1c4b-4281-b951-d872f2087c98
* Bug fixing for range request support in HttpCachehclam@chromium.org2009-09-051-0/+35
| | | | | | | | | | | | | | | | | | | TEST=net_unittests --gtest_filter=HttpCache.GET_Previous206_NotModified Step to reproduce the failure: 1. Sparse cache has data for (0 - 9) 2. Make a non-range request for the resource 3. Server replies with 304 not modified 4. User would get 304 modified while 200 is expected The cause is that PartialData::ResponseHeadersOK requires a full specified range to accept the response when server replies with 304. This is not a valid assumption as the response of 304 can be caused by the cache submitting a range request for validation purpose. Review URL: http://codereview.chromium.org/198018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25569 0039d316-1c4b-4281-b951-d872f2087c98
* Http Cache: Add support for resuming downloading arvargas@google.com2009-09-041-2/+155
| | | | | | | | | | | | resource after the original request was interrupted. BUG=8995 TEST=unittests Review URL: http://codereview.chromium.org/197016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25551 0039d316-1c4b-4281-b951-d872f2087c98
* Update the request time of http cache entries on 304.eroman@chromium.org2009-09-041-6/+14
| | | | | | | | | BUG=http://crbug.com/20594 TEST=HttpCache.UpdatesRequestResponseTimeOn304 Review URL: http://codereview.chromium.org/199028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25541 0039d316-1c4b-4281-b951-d872f2087c98
* Update the response time of http cache entries on 304.eroman@chromium.org2009-09-041-6/+85
| | | | | | | | | BUG=http://crbug.com/20594 TEST=HttpCacheTest.UpdatesResponseTimeOn304 Review URL: http://codereview.chromium.org/197024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25484 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Bypass the cache for range requests that have validation headers.rvargas@google.com2009-08-281-1/+33
| | | | | | | | | BUG=20017 TEST=unittests Review URL: http://codereview.chromium.org/177016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24759 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Enable experimental support for byte range requests.rvargas@google.com2009-08-241-15/+30
| | | | | | | | | | | Requires --enable-byte-range-support BUG=12258 TEST=covered by unit tests. Review URL: http://codereview.chromium.org/173231 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24113 0039d316-1c4b-4281-b951-d872f2087c98
* Revert cl 24015rvargas@google.com2009-08-211-30/+15
| | | | | | | | | BUG=none TEST=none Review URL: http://codereview.chromium.org/174260 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24026 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Enable experimental support for byte range requests.rvargas@google.com2009-08-211-15/+30
| | | | | | | | | | | Requires --enable-byte-range-support BUG=12258 TEST=covered by unit tests. Review URL: http://codereview.chromium.org/173173 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24015 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Fix the code that handles 206s when revalidatingrvargas@google.com2009-08-201-1/+45
| | | | | | | | | | | a range from the cache. BUG=12258 TEST=unittests Review URL: http://codereview.chromium.org/174039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23881 0039d316-1c4b-4281-b951-d872f2087c98
* Http Cache: Additional byte-range support.rvargas@google.com2009-08-181-29/+204
| | | | | | | | | | | | | | | | | | | | * Now we can serve byte range requests from cached 200s. * When we receive 304 we make sure that we were expecting it. * A range request that doesn't fit the currently stored entry only deletes the entry if the server confirms that it has changed. * Make sure that LOAD_ONLY_FROM_CACHE causes cache misses for byte range requests. BUG=12258 TEST=unittests Review URL: http://codereview.chromium.org/165479 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23601 0039d316-1c4b-4281-b951-d872f2087c98
* LoadLog is used as an output parameter, reorder it to the last parameter.willchan@chromium.org2009-08-141-14/+14
| | | | | | Review URL: http://codereview.chromium.org/164531 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23419 0039d316-1c4b-4281-b951-d872f2087c98
* Add a "LoadLog" parameter to transactions, hostresolver, clientsocketpool ↵ericroman@google.com2009-08-121-14/+14
| | | | | | | | and proyxservice.This dependency comes from the parent URLRequest, and is used as a container for per-request profiling data.This change is strictly a no-op refactor -- the parameter is unused, and LoadLog does nothing.BUG=http://crbug.com/14478TEST=none -- just needs to compile and pass existing tests.DESIGN=<http://docs.google.com/Doc?id=dfhcnb2v_21gbtrcpr3&hl=en> Review URL: http://codereview.chromium.org/126303 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23127 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Extend support for byte range requests.rvargas@google.com2009-08-121-9/+183
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Now we handle regular requests (not byte range requests) that end up reading a cached entry that stores byte ranges. In this case we create a control object (partial_), but it's byte_range_ member is always invalid because the user is not requesting a range. * Given that we may find stored 206s that are not keeping sparse data, we detect that case and handle it. * Now we may end up reading 206 from disk (and the net) and having to change the returned status to be 200 (for regular requests). * We avoid performing re-validations for each piece of stored data. Instead, we consider the whole entry to be revalidated once, and read from the cache without asking the server (as far as we can). * When processing the received headers we now consider receiving 200 and 416 (instead of 206/304) and we handle inconsistencies in the range returned by the server (from what we expect). We also handle receiving 206 when we don't expect it. BUG=12258 TEST=unittests Review URL: http://codereview.chromium.org/164304 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23123 0039d316-1c4b-4281-b951-d872f2087c98
* Http Cache: Deactivate entries without having the key of thervargas@google.com2009-08-071-5/+60
| | | | | | | | | | | | | | | entry to delete. The disk cache may fail to provide the key for a given entry (if there is a disk error, for instance), so we fall back to enumerate the active entries to delete this one. BUG=9952 TEST=unittest Review URL: http://codereview.chromium.org/165089 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22701 0039d316-1c4b-4281-b951-d872f2087c98
* Support user-constructed conditional requests to HttpCache updating the cache.ericroman@google.com2009-08-031-30/+265
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are requests where conditionalization is specified through |extra_headers| rather than through a load flag (LOAD_VALIDATE_CACHE). The previous behavior was that such requests would disable caching. So any more up-to-date response discovered by an "if-modifed-since" request was never written back to the cache. BUG=http://crbug.com/16199 TEST=HttpCache unit tes Overview for how these requests are dealt with: (1) When starting the request, check for an "if-modified-since" or "if-none-match" request header. If one is found: * let it be called |external_validation_header| * continue to (2). (2) Parse |external_validation_header| to obtain either an |etag| or a |last_modified_date|. (3) Read the HTTP cache entry for URL. Call the result |entry|. (4) Now that we have read the cache entry, check if |external_validation_header| defines a validation request for |entry|. We cannot assume that |external_validation_header| makes sense in the context of |entry|, since the headers are free-form text originating from WebCore, and could be unrelated to the cache entry. If any of the following are true, then |external_validation_header| does NOT define a validation request for |entry|: * |entry| is undefined (was not found in step (3)). * |entry| has no "etag" or "last-modified" headers. * |entry| has a "last-modified" header, but it is not equal to |external_validation_header|'s |last_modified_date|. * |entry| has an "etag" header, but it does not match |external_validation_header|'s |etag|. Let |is_validation_request| be the result of this test. If |is_validation_request|, then we can safely use the response from the subsequent network response to update |entry|. If |!is_validation_request|, then we disable caching before proceeding on to the network request. NOTE: we turned off writing back to cache in this case, since a 304 response received from the server doesn't tell us anything about our cache entry. And moreover trying to handle a non-304 response would be awkward to deal with since the transaction would have to enter a "maybe will write to cache" state. (5) Start the network transaction. (6) On completion of the network transaction: if we are doing an internal OR an external validation request: if |http_code == 304| update |entry|'s response headers with the new response headers. if it was externally conditionalized: return the received response (304) to the user else if it was internally conditionalized: return the cached response (200) to the user Review URL: http://codereview.chromium.org/159463 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22328 0039d316-1c4b-4281-b951-d872f2087c98
* Strip embedded "#" in URLs when constructing HTTP cache key.ericroman@google.com2009-07-231-2/+26
| | | | | | | | | BUG=http://crbug.com/17493 TEST=HttpCache.UrlContainingHash Review URL: http://codereview.chromium.org/155972 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21408 0039d316-1c4b-4281-b951-d872f2087c98
* Add unit-test for 16199, to check caching behavior of conditonalized cache ↵ericroman@google.com2009-07-231-3/+132
| | | | | | | | | | | | requests (if-modified-since). This test does not pass, and is currently disabled -- it will be enabled once 16199 is fixed. BUG=http://crbug.com/16199 Review URL: http://codereview.chromium.org/159220 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21359 0039d316-1c4b-4281-b951-d872f2087c98
* Fix a browser crash during cache validation.rvargas@google.com2009-06-301-0/+24
| | | | | | | | | | | | | | | It is possible for a crazy server to return 206 even though we are not making a range request. In that case, we should not allow the stored response to go through the logic for range support (which right now is disabled). We've always stored those 206s though. BUG=15617 TEST=unittest Review URL: http://codereview.chromium.org/150090 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19621 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Add support for ranges with an unknown start or end.rvargas@google.com2009-06-241-1/+73
| | | | | | | | | BUG=12258 TEST=unittest Review URL: http://codereview.chromium.org/147042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19142 0039d316-1c4b-4281-b951-d872f2087c98
* Http cache: Return valid Content-Range headers for a byte range request.rvargas@google.com2009-06-221-8/+57
| | | | | | | | | BUG=12258 TEST=unittests Review URL: http://codereview.chromium.org/140015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18961 0039d316-1c4b-4281-b951-d872f2087c98
* Http Cache: First pass of byte-range requests support.rvargas@google.com2009-06-121-4/+126
| | | | | | | | | | | | | | | | | | | | | | This is the first pass to implement support for range requests and the asociated sparse cache entry. It is disabled by default, and requires ENABLE_RANGE_SUPPORT to be defined in order to activate the code: all the code is compiled in, but Start() bypasses the cache for range requests, and OnNetworkInfoAvailable ignores 206. Big parts are still not implemented. Most notably we are not modifying the response headers that we send to the user, so the content-range and content-length info are not correct. BUG=12258 TEST=Unit tests. Review URL: http://codereview.chromium.org/118345 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18289 0039d316-1c4b-4281-b951-d872f2087c98
* Add two small features to the HttpCache for benchmarking/debugging.mbelshe@google.com2009-06-051-0/+20
| | | | | | | | | | | | | | | | | | The first exposes a method to close all idle sockets. This allows me to create benchmark tests in the app which can close connections before starting the test for better simulations. The second change is to expose cache modes for cache disabled and cache bypassed. DISABLE sets the LOAD_DISABLE_CACHE on every request; BYPASS sets the LOAD_BYPASS_CACHE on every request. TEST=http_cache_unittest.cc BUG=6754 Review URL: http://codereview.chromium.org/119189 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17720 0039d316-1c4b-4281-b951-d872f2087c98