| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_transaction.h" | 5 #include "net/http/http_cache_transaction.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_POSIX) | 9 #if defined(OS_POSIX) |
| 10 #include <unistd.h> | 10 #include <unistd.h> |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 | 645 |
| 646 if (rv != ERR_IO_PENDING) | 646 if (rv != ERR_IO_PENDING) |
| 647 HandleResult(rv); | 647 HandleResult(rv); |
| 648 | 648 |
| 649 return rv; | 649 return rv; |
| 650 } | 650 } |
| 651 | 651 |
| 652 int HttpCache::Transaction::DoGetBackend() { | 652 int HttpCache::Transaction::DoGetBackend() { |
| 653 cache_pending_ = true; | 653 cache_pending_ = true; |
| 654 next_state_ = STATE_GET_BACKEND_COMPLETE; | 654 next_state_ = STATE_GET_BACKEND_COMPLETE; |
| 655 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_GET_BACKEND, NULL); | 655 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_GET_BACKEND); |
| 656 return cache_->GetBackendForTransaction(this); | 656 return cache_->GetBackendForTransaction(this); |
| 657 } | 657 } |
| 658 | 658 |
| 659 int HttpCache::Transaction::DoGetBackendComplete(int result) { | 659 int HttpCache::Transaction::DoGetBackendComplete(int result) { |
| 660 DCHECK(result == OK || result == ERR_FAILED); | 660 DCHECK(result == OK || result == ERR_FAILED); |
| 661 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_GET_BACKEND, | 661 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_GET_BACKEND, |
| 662 result); | 662 result); |
| 663 cache_pending_ = false; | 663 cache_pending_ = false; |
| 664 | 664 |
| 665 if (!ShouldPassThrough()) { | 665 if (!ShouldPassThrough()) { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 } | 838 } |
| 839 | 839 |
| 840 next_state_ = STATE_OPEN_ENTRY; | 840 next_state_ = STATE_OPEN_ENTRY; |
| 841 return OK; | 841 return OK; |
| 842 } | 842 } |
| 843 | 843 |
| 844 int HttpCache::Transaction::DoOpenEntry() { | 844 int HttpCache::Transaction::DoOpenEntry() { |
| 845 DCHECK(!new_entry_); | 845 DCHECK(!new_entry_); |
| 846 next_state_ = STATE_OPEN_ENTRY_COMPLETE; | 846 next_state_ = STATE_OPEN_ENTRY_COMPLETE; |
| 847 cache_pending_ = true; | 847 cache_pending_ = true; |
| 848 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY, NULL); | 848 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY); |
| 849 return cache_->OpenEntry(cache_key_, &new_entry_, this); | 849 return cache_->OpenEntry(cache_key_, &new_entry_, this); |
| 850 } | 850 } |
| 851 | 851 |
| 852 int HttpCache::Transaction::DoOpenEntryComplete(int result) { | 852 int HttpCache::Transaction::DoOpenEntryComplete(int result) { |
| 853 // It is important that we go to STATE_ADD_TO_ENTRY whenever the result is | 853 // It is important that we go to STATE_ADD_TO_ENTRY whenever the result is |
| 854 // OK, otherwise the cache will end up with an active entry without any | 854 // OK, otherwise the cache will end up with an active entry without any |
| 855 // transaction attached. | 855 // transaction attached. |
| 856 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY, result); | 856 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_OPEN_ENTRY, result); |
| 857 cache_pending_ = false; | 857 cache_pending_ = false; |
| 858 if (result == OK) { | 858 if (result == OK) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 888 | 888 |
| 889 // The entry does not exist, and we are not permitted to create a new entry, | 889 // The entry does not exist, and we are not permitted to create a new entry, |
| 890 // so we must fail. | 890 // so we must fail. |
| 891 return ERR_CACHE_MISS; | 891 return ERR_CACHE_MISS; |
| 892 } | 892 } |
| 893 | 893 |
| 894 int HttpCache::Transaction::DoCreateEntry() { | 894 int HttpCache::Transaction::DoCreateEntry() { |
| 895 DCHECK(!new_entry_); | 895 DCHECK(!new_entry_); |
| 896 next_state_ = STATE_CREATE_ENTRY_COMPLETE; | 896 next_state_ = STATE_CREATE_ENTRY_COMPLETE; |
| 897 cache_pending_ = true; | 897 cache_pending_ = true; |
| 898 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY, NULL); | 898 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY); |
| 899 return cache_->CreateEntry(cache_key_, &new_entry_, this); | 899 return cache_->CreateEntry(cache_key_, &new_entry_, this); |
| 900 } | 900 } |
| 901 | 901 |
| 902 int HttpCache::Transaction::DoCreateEntryComplete(int result) { | 902 int HttpCache::Transaction::DoCreateEntryComplete(int result) { |
| 903 // It is important that we go to STATE_ADD_TO_ENTRY whenever the result is | 903 // It is important that we go to STATE_ADD_TO_ENTRY whenever the result is |
| 904 // OK, otherwise the cache will end up with an active entry without any | 904 // OK, otherwise the cache will end up with an active entry without any |
| 905 // transaction attached. | 905 // transaction attached. |
| 906 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY, | 906 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_CREATE_ENTRY, |
| 907 result); | 907 result); |
| 908 cache_pending_ = false; | 908 cache_pending_ = false; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 923 if (partial_.get()) | 923 if (partial_.get()) |
| 924 partial_->RestoreHeaders(&custom_request_->extra_headers); | 924 partial_->RestoreHeaders(&custom_request_->extra_headers); |
| 925 next_state_ = STATE_SEND_REQUEST; | 925 next_state_ = STATE_SEND_REQUEST; |
| 926 } | 926 } |
| 927 return OK; | 927 return OK; |
| 928 } | 928 } |
| 929 | 929 |
| 930 int HttpCache::Transaction::DoDoomEntry() { | 930 int HttpCache::Transaction::DoDoomEntry() { |
| 931 next_state_ = STATE_DOOM_ENTRY_COMPLETE; | 931 next_state_ = STATE_DOOM_ENTRY_COMPLETE; |
| 932 cache_pending_ = true; | 932 cache_pending_ = true; |
| 933 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_DOOM_ENTRY, NULL); | 933 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_DOOM_ENTRY); |
| 934 return cache_->DoomEntry(cache_key_, this); | 934 return cache_->DoomEntry(cache_key_, this); |
| 935 } | 935 } |
| 936 | 936 |
| 937 int HttpCache::Transaction::DoDoomEntryComplete(int result) { | 937 int HttpCache::Transaction::DoDoomEntryComplete(int result) { |
| 938 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_DOOM_ENTRY, result); | 938 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_DOOM_ENTRY, result); |
| 939 next_state_ = STATE_CREATE_ENTRY; | 939 next_state_ = STATE_CREATE_ENTRY; |
| 940 cache_pending_ = false; | 940 cache_pending_ = false; |
| 941 if (result == ERR_CACHE_RACE) | 941 if (result == ERR_CACHE_RACE) |
| 942 next_state_ = STATE_INIT_ENTRY; | 942 next_state_ = STATE_INIT_ENTRY; |
| 943 | 943 |
| 944 return OK; | 944 return OK; |
| 945 } | 945 } |
| 946 | 946 |
| 947 int HttpCache::Transaction::DoAddToEntry() { | 947 int HttpCache::Transaction::DoAddToEntry() { |
| 948 DCHECK(new_entry_); | 948 DCHECK(new_entry_); |
| 949 cache_pending_ = true; | 949 cache_pending_ = true; |
| 950 next_state_ = STATE_ADD_TO_ENTRY_COMPLETE; | 950 next_state_ = STATE_ADD_TO_ENTRY_COMPLETE; |
| 951 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY, NULL); | 951 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY); |
| 952 DCHECK(entry_lock_waiting_since_.is_null()); | 952 DCHECK(entry_lock_waiting_since_.is_null()); |
| 953 entry_lock_waiting_since_ = base::TimeTicks::Now(); | 953 entry_lock_waiting_since_ = base::TimeTicks::Now(); |
| 954 return cache_->AddTransactionToEntry(new_entry_, this); | 954 return cache_->AddTransactionToEntry(new_entry_, this); |
| 955 } | 955 } |
| 956 | 956 |
| 957 int HttpCache::Transaction::DoAddToEntryComplete(int result) { | 957 int HttpCache::Transaction::DoAddToEntryComplete(int result) { |
| 958 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY, | 958 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_ADD_TO_ENTRY, |
| 959 result); | 959 result); |
| 960 | 960 |
| 961 const base::TimeDelta entry_lock_wait = | 961 const base::TimeDelta entry_lock_wait = |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 next_state_ = truncated_ ? STATE_CACHE_WRITE_TRUNCATED_RESPONSE : | 1128 next_state_ = truncated_ ? STATE_CACHE_WRITE_TRUNCATED_RESPONSE : |
| 1129 STATE_CACHE_WRITE_RESPONSE; | 1129 STATE_CACHE_WRITE_RESPONSE; |
| 1130 return OK; | 1130 return OK; |
| 1131 } | 1131 } |
| 1132 | 1132 |
| 1133 int HttpCache::Transaction::DoTruncateCachedData() { | 1133 int HttpCache::Transaction::DoTruncateCachedData() { |
| 1134 next_state_ = STATE_TRUNCATE_CACHED_DATA_COMPLETE; | 1134 next_state_ = STATE_TRUNCATE_CACHED_DATA_COMPLETE; |
| 1135 if (!entry_) | 1135 if (!entry_) |
| 1136 return OK; | 1136 return OK; |
| 1137 if (net_log_.IsLoggingAllEvents()) | 1137 if (net_log_.IsLoggingAllEvents()) |
| 1138 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_DATA, NULL); | 1138 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_DATA); |
| 1139 | 1139 |
| 1140 // Truncate the stream. | 1140 // Truncate the stream. |
| 1141 return WriteToEntry(kResponseContentIndex, 0, NULL, 0, io_callback_); | 1141 return WriteToEntry(kResponseContentIndex, 0, NULL, 0, io_callback_); |
| 1142 } | 1142 } |
| 1143 | 1143 |
| 1144 int HttpCache::Transaction::DoTruncateCachedDataComplete(int result) { | 1144 int HttpCache::Transaction::DoTruncateCachedDataComplete(int result) { |
| 1145 if (net_log_.IsLoggingAllEvents() && entry_) { | 1145 if (net_log_.IsLoggingAllEvents() && entry_) { |
| 1146 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_DATA, | 1146 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_DATA, |
| 1147 result); | 1147 result); |
| 1148 } | 1148 } |
| 1149 | 1149 |
| 1150 next_state_ = STATE_TRUNCATE_CACHED_METADATA; | 1150 next_state_ = STATE_TRUNCATE_CACHED_METADATA; |
| 1151 return OK; | 1151 return OK; |
| 1152 } | 1152 } |
| 1153 | 1153 |
| 1154 int HttpCache::Transaction::DoTruncateCachedMetadata() { | 1154 int HttpCache::Transaction::DoTruncateCachedMetadata() { |
| 1155 next_state_ = STATE_TRUNCATE_CACHED_METADATA_COMPLETE; | 1155 next_state_ = STATE_TRUNCATE_CACHED_METADATA_COMPLETE; |
| 1156 if (!entry_) | 1156 if (!entry_) |
| 1157 return OK; | 1157 return OK; |
| 1158 | 1158 |
| 1159 if (net_log_.IsLoggingAllEvents()) | 1159 if (net_log_.IsLoggingAllEvents()) |
| 1160 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, NULL); | 1160 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO); |
| 1161 return WriteToEntry(kMetadataIndex, 0, NULL, 0, io_callback_); | 1161 return WriteToEntry(kMetadataIndex, 0, NULL, 0, io_callback_); |
| 1162 } | 1162 } |
| 1163 | 1163 |
| 1164 int HttpCache::Transaction::DoTruncateCachedMetadataComplete(int result) { | 1164 int HttpCache::Transaction::DoTruncateCachedMetadataComplete(int result) { |
| 1165 if (net_log_.IsLoggingAllEvents() && entry_) { | 1165 if (net_log_.IsLoggingAllEvents() && entry_) { |
| 1166 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, | 1166 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, |
| 1167 result); | 1167 result); |
| 1168 } | 1168 } |
| 1169 | 1169 |
| 1170 // If this response is a redirect, then we can stop writing now. (We don't | 1170 // If this response is a redirect, then we can stop writing now. (We don't |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1198 return OK; | 1198 return OK; |
| 1199 } | 1199 } |
| 1200 | 1200 |
| 1201 int HttpCache::Transaction::DoCacheReadResponse() { | 1201 int HttpCache::Transaction::DoCacheReadResponse() { |
| 1202 DCHECK(entry_); | 1202 DCHECK(entry_); |
| 1203 next_state_ = STATE_CACHE_READ_RESPONSE_COMPLETE; | 1203 next_state_ = STATE_CACHE_READ_RESPONSE_COMPLETE; |
| 1204 | 1204 |
| 1205 io_buf_len_ = entry_->disk_entry->GetDataSize(kResponseInfoIndex); | 1205 io_buf_len_ = entry_->disk_entry->GetDataSize(kResponseInfoIndex); |
| 1206 read_buf_ = new IOBuffer(io_buf_len_); | 1206 read_buf_ = new IOBuffer(io_buf_len_); |
| 1207 | 1207 |
| 1208 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO, NULL); | 1208 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO); |
| 1209 return entry_->disk_entry->ReadData(kResponseInfoIndex, 0, read_buf_, | 1209 return entry_->disk_entry->ReadData(kResponseInfoIndex, 0, read_buf_, |
| 1210 io_buf_len_, io_callback_); | 1210 io_buf_len_, io_callback_); |
| 1211 } | 1211 } |
| 1212 | 1212 |
| 1213 int HttpCache::Transaction::DoCacheReadResponseComplete(int result) { | 1213 int HttpCache::Transaction::DoCacheReadResponseComplete(int result) { |
| 1214 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_INFO, result); | 1214 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_INFO, result); |
| 1215 if (result != io_buf_len_ || | 1215 if (result != io_buf_len_ || |
| 1216 !HttpCache::ParseResponseInfo(read_buf_->data(), io_buf_len_, | 1216 !HttpCache::ParseResponseInfo(read_buf_->data(), io_buf_len_, |
| 1217 &response_, &truncated_)) { | 1217 &response_, &truncated_)) { |
| 1218 return OnCacheReadError(result, true); | 1218 return OnCacheReadError(result, true); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1249 case WRITE: | 1249 case WRITE: |
| 1250 default: | 1250 default: |
| 1251 NOTREACHED(); | 1251 NOTREACHED(); |
| 1252 result = ERR_FAILED; | 1252 result = ERR_FAILED; |
| 1253 } | 1253 } |
| 1254 return result; | 1254 return result; |
| 1255 } | 1255 } |
| 1256 | 1256 |
| 1257 int HttpCache::Transaction::DoCacheWriteResponse() { | 1257 int HttpCache::Transaction::DoCacheWriteResponse() { |
| 1258 if (net_log_.IsLoggingAllEvents() && entry_) | 1258 if (net_log_.IsLoggingAllEvents() && entry_) |
| 1259 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, NULL); | 1259 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO); |
| 1260 return WriteResponseInfoToEntry(false); | 1260 return WriteResponseInfoToEntry(false); |
| 1261 } | 1261 } |
| 1262 | 1262 |
| 1263 int HttpCache::Transaction::DoCacheWriteTruncatedResponse() { | 1263 int HttpCache::Transaction::DoCacheWriteTruncatedResponse() { |
| 1264 if (net_log_.IsLoggingAllEvents() && entry_) | 1264 if (net_log_.IsLoggingAllEvents() && entry_) |
| 1265 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, NULL); | 1265 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_INFO); |
| 1266 return WriteResponseInfoToEntry(true); | 1266 return WriteResponseInfoToEntry(true); |
| 1267 } | 1267 } |
| 1268 | 1268 |
| 1269 int HttpCache::Transaction::DoCacheWriteResponseComplete(int result) { | 1269 int HttpCache::Transaction::DoCacheWriteResponseComplete(int result) { |
| 1270 next_state_ = target_state_; | 1270 next_state_ = target_state_; |
| 1271 target_state_ = STATE_NONE; | 1271 target_state_ = STATE_NONE; |
| 1272 if (!entry_) | 1272 if (!entry_) |
| 1273 return OK; | 1273 return OK; |
| 1274 if (net_log_.IsLoggingAllEvents()) { | 1274 if (net_log_.IsLoggingAllEvents()) { |
| 1275 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, | 1275 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_INFO, |
| 1276 result); | 1276 result); |
| 1277 } | 1277 } |
| 1278 | 1278 |
| 1279 // Balance the AddRef from WriteResponseInfoToEntry. | 1279 // Balance the AddRef from WriteResponseInfoToEntry. |
| 1280 if (result != io_buf_len_) { | 1280 if (result != io_buf_len_) { |
| 1281 DLOG(ERROR) << "failed to write response info to cache"; | 1281 DLOG(ERROR) << "failed to write response info to cache"; |
| 1282 DoneWritingToEntry(false); | 1282 DoneWritingToEntry(false); |
| 1283 } | 1283 } |
| 1284 return OK; | 1284 return OK; |
| 1285 } | 1285 } |
| 1286 | 1286 |
| 1287 int HttpCache::Transaction::DoCacheReadMetadata() { | 1287 int HttpCache::Transaction::DoCacheReadMetadata() { |
| 1288 DCHECK(entry_); | 1288 DCHECK(entry_); |
| 1289 DCHECK(!response_.metadata); | 1289 DCHECK(!response_.metadata); |
| 1290 next_state_ = STATE_CACHE_READ_METADATA_COMPLETE; | 1290 next_state_ = STATE_CACHE_READ_METADATA_COMPLETE; |
| 1291 | 1291 |
| 1292 response_.metadata = | 1292 response_.metadata = |
| 1293 new IOBufferWithSize(entry_->disk_entry->GetDataSize(kMetadataIndex)); | 1293 new IOBufferWithSize(entry_->disk_entry->GetDataSize(kMetadataIndex)); |
| 1294 | 1294 |
| 1295 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO, NULL); | 1295 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO); |
| 1296 return entry_->disk_entry->ReadData(kMetadataIndex, 0, response_.metadata, | 1296 return entry_->disk_entry->ReadData(kMetadataIndex, 0, response_.metadata, |
| 1297 response_.metadata->size(), | 1297 response_.metadata->size(), |
| 1298 io_callback_); | 1298 io_callback_); |
| 1299 } | 1299 } |
| 1300 | 1300 |
| 1301 int HttpCache::Transaction::DoCacheReadMetadataComplete(int result) { | 1301 int HttpCache::Transaction::DoCacheReadMetadataComplete(int result) { |
| 1302 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_INFO, result); | 1302 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_READ_INFO, result); |
| 1303 if (result != response_.metadata->size()) | 1303 if (result != response_.metadata->size()) |
| 1304 return OnCacheReadError(result, false); | 1304 return OnCacheReadError(result, false); |
| 1305 | 1305 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1319 return ERR_UNEXPECTED; | 1319 return ERR_UNEXPECTED; |
| 1320 | 1320 |
| 1321 return ValidateEntryHeadersAndContinue(); | 1321 return ValidateEntryHeadersAndContinue(); |
| 1322 } | 1322 } |
| 1323 | 1323 |
| 1324 int HttpCache::Transaction::DoCacheReadData() { | 1324 int HttpCache::Transaction::DoCacheReadData() { |
| 1325 DCHECK(entry_); | 1325 DCHECK(entry_); |
| 1326 next_state_ = STATE_CACHE_READ_DATA_COMPLETE; | 1326 next_state_ = STATE_CACHE_READ_DATA_COMPLETE; |
| 1327 | 1327 |
| 1328 if (net_log_.IsLoggingAllEvents()) | 1328 if (net_log_.IsLoggingAllEvents()) |
| 1329 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_DATA, NULL); | 1329 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_DATA); |
| 1330 if (partial_.get()) { | 1330 if (partial_.get()) { |
| 1331 return partial_->CacheRead(entry_->disk_entry, read_buf_, io_buf_len_, | 1331 return partial_->CacheRead(entry_->disk_entry, read_buf_, io_buf_len_, |
| 1332 io_callback_); | 1332 io_callback_); |
| 1333 } | 1333 } |
| 1334 | 1334 |
| 1335 return entry_->disk_entry->ReadData(kResponseContentIndex, read_offset_, | 1335 return entry_->disk_entry->ReadData(kResponseContentIndex, read_offset_, |
| 1336 read_buf_, io_buf_len_, io_callback_); | 1336 read_buf_, io_buf_len_, io_callback_); |
| 1337 } | 1337 } |
| 1338 | 1338 |
| 1339 int HttpCache::Transaction::DoCacheReadDataComplete(int result) { | 1339 int HttpCache::Transaction::DoCacheReadDataComplete(int result) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1356 } else { | 1356 } else { |
| 1357 return OnCacheReadError(result, false); | 1357 return OnCacheReadError(result, false); |
| 1358 } | 1358 } |
| 1359 return result; | 1359 return result; |
| 1360 } | 1360 } |
| 1361 | 1361 |
| 1362 int HttpCache::Transaction::DoCacheWriteData(int num_bytes) { | 1362 int HttpCache::Transaction::DoCacheWriteData(int num_bytes) { |
| 1363 next_state_ = STATE_CACHE_WRITE_DATA_COMPLETE; | 1363 next_state_ = STATE_CACHE_WRITE_DATA_COMPLETE; |
| 1364 write_len_ = num_bytes; | 1364 write_len_ = num_bytes; |
| 1365 if (net_log_.IsLoggingAllEvents() && entry_) | 1365 if (net_log_.IsLoggingAllEvents() && entry_) |
| 1366 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_DATA, NULL); | 1366 net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_WRITE_DATA); |
| 1367 | 1367 |
| 1368 return AppendResponseDataToEntry(read_buf_, num_bytes, io_callback_); | 1368 return AppendResponseDataToEntry(read_buf_, num_bytes, io_callback_); |
| 1369 } | 1369 } |
| 1370 | 1370 |
| 1371 int HttpCache::Transaction::DoCacheWriteDataComplete(int result) { | 1371 int HttpCache::Transaction::DoCacheWriteDataComplete(int result) { |
| 1372 if (net_log_.IsLoggingAllEvents() && entry_) { | 1372 if (net_log_.IsLoggingAllEvents() && entry_) { |
| 1373 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_DATA, | 1373 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_HTTP_CACHE_WRITE_DATA, |
| 1374 result); | 1374 result); |
| 1375 } | 1375 } |
| 1376 // Balance the AddRef from DoCacheWriteData. | 1376 // Balance the AddRef from DoCacheWriteData. |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2105 return false; | 2105 return false; |
| 2106 | 2106 |
| 2107 return true; | 2107 return true; |
| 2108 } | 2108 } |
| 2109 | 2109 |
| 2110 void HttpCache::Transaction::OnIOComplete(int result) { | 2110 void HttpCache::Transaction::OnIOComplete(int result) { |
| 2111 DoLoop(result); | 2111 DoLoop(result); |
| 2112 } | 2112 } |
| 2113 | 2113 |
| 2114 } // namespace net | 2114 } // namespace net |
| OLD | NEW |