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

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

Issue 2812062: Http Cache: Make sure that we don't fail transactions when the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 5 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/http/http_cache_transaction.cc ('k') | no next file » | 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 CallbackLater(callback, num); 130 CallbackLater(callback, num);
131 return net::ERR_IO_PENDING; 131 return net::ERR_IO_PENDING;
132 } 132 }
133 133
134 virtual int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len, 134 virtual int WriteData(int index, int offset, net::IOBuffer* buf, int buf_len,
135 net::CompletionCallback* callback, bool truncate) { 135 net::CompletionCallback* callback, bool truncate) {
136 DCHECK(index >= 0 && index < kNumCacheEntryDataIndices); 136 DCHECK(index >= 0 && index < kNumCacheEntryDataIndices);
137 DCHECK(callback); 137 DCHECK(callback);
138 DCHECK(truncate); 138 DCHECK(truncate);
139 139
140 if (fail_requests_) 140 if (fail_requests_) {
141 return net::ERR_CACHE_READ_FAILURE; 141 CallbackLater(callback, net::ERR_CACHE_READ_FAILURE);
142 return net::ERR_IO_PENDING;
143 }
142 144
143 if (offset < 0 || offset > static_cast<int>(data_[index].size())) 145 if (offset < 0 || offset > static_cast<int>(data_[index].size()))
144 return net::ERR_FAILED; 146 return net::ERR_FAILED;
145 147
146 data_[index].resize(offset + buf_len); 148 data_[index].resize(offset + buf_len);
147 if (buf_len) 149 if (buf_len)
148 memcpy(&data_[index][offset], buf->data(), buf_len); 150 memcpy(&data_[index][offset], buf->data(), buf_len);
149 151
150 if (GetEffectiveTestMode(test_mode_) & TEST_MODE_SYNC_CACHE_WRITE) 152 if (GetEffectiveTestMode(test_mode_) & TEST_MODE_SYNC_CACHE_WRITE)
151 return buf_len; 153 return buf_len;
(...skipping 4572 matching lines...) Expand 10 before | Expand all | Expand 10 after
4724 // Now return 200 when validating the entry so the metadata will be lost. 4726 // Now return 200 when validating the entry so the metadata will be lost.
4725 MockTransaction trans2(kTypicalGET_Transaction); 4727 MockTransaction trans2(kTypicalGET_Transaction);
4726 trans2.load_flags = net::LOAD_VALIDATE_CACHE; 4728 trans2.load_flags = net::LOAD_VALIDATE_CACHE;
4727 RunTransactionTestWithResponseInfo(cache.http_cache(), trans2, &response); 4729 RunTransactionTestWithResponseInfo(cache.http_cache(), trans2, &response);
4728 EXPECT_TRUE(response.metadata.get() == NULL); 4730 EXPECT_TRUE(response.metadata.get() == NULL);
4729 4731
4730 EXPECT_EQ(3, cache.network_layer()->transaction_count()); 4732 EXPECT_EQ(3, cache.network_layer()->transaction_count());
4731 EXPECT_EQ(4, cache.disk_cache()->open_count()); 4733 EXPECT_EQ(4, cache.disk_cache()->open_count());
4732 EXPECT_EQ(1, cache.disk_cache()->create_count()); 4734 EXPECT_EQ(1, cache.disk_cache()->create_count());
4733 } 4735 }
OLDNEW
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698