OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/disk_cache_based_quic_server_info.h" | 5 #include "net/http/disk_cache_based_quic_server_info.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "net/base/completion_callback.h" | 10 #include "net/base/completion_callback.h" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 | 206 |
207 int DiskCacheBasedQuicServerInfo::DoReadComplete(int rv) { | 207 int DiskCacheBasedQuicServerInfo::DoReadComplete(int rv) { |
208 if (rv > 0) | 208 if (rv > 0) |
209 data_.assign(read_buffer_->data(), rv); | 209 data_.assign(read_buffer_->data(), rv); |
210 | 210 |
211 state_ = WAIT_FOR_DATA_READY_DONE; | 211 state_ = WAIT_FOR_DATA_READY_DONE; |
212 return OK; | 212 return OK; |
213 } | 213 } |
214 | 214 |
215 int DiskCacheBasedQuicServerInfo::DoWriteComplete(int rv) { | 215 int DiskCacheBasedQuicServerInfo::DoWriteComplete(int rv) { |
216 state_ = SET_DONE; | 216 // Keep the entry open for future writes. |
217 new_data_.clear(); | |
218 state_ = NONE; | |
217 return OK; | 219 return OK; |
218 } | 220 } |
219 | 221 |
220 int DiskCacheBasedQuicServerInfo::DoCreateOrOpenComplete(int rv) { | 222 int DiskCacheBasedQuicServerInfo::DoCreateOrOpenComplete(int rv) { |
221 if (rv != OK) { | 223 if (rv != OK) { |
222 state_ = SET_DONE; | 224 state_ = SET_DONE; |
223 } else { | 225 } else { |
224 entry_ = data_shim_->entry; | 226 if (!entry_) |
227 entry_ = data_shim_->entry; | |
rjshade
2014/09/18 19:42:51
Chromium style guide doesn't require {} around sin
Ryan Hamilton
2014/09/18 19:52:52
Nope; Chrome's unofficial net/ style guide prohibi
| |
225 state_ = WRITE; | 228 state_ = WRITE; |
226 } | 229 } |
227 return OK; | 230 return OK; |
228 } | 231 } |
229 | 232 |
230 int DiskCacheBasedQuicServerInfo::DoGetBackend() { | 233 int DiskCacheBasedQuicServerInfo::DoGetBackend() { |
231 state_ = GET_BACKEND_COMPLETE; | 234 state_ = GET_BACKEND_COMPLETE; |
232 return http_cache_->GetBackend(&data_shim_->backend, io_callback_); | 235 return http_cache_->GetBackend(&data_shim_->backend, io_callback_); |
233 } | 236 } |
234 | 237 |
(...skipping 22 matching lines...) Expand all Loading... | |
257 | 260 |
258 return entry_->WriteData(0 /* index */, | 261 return entry_->WriteData(0 /* index */, |
259 0 /* offset */, | 262 0 /* offset */, |
260 write_buffer_.get(), | 263 write_buffer_.get(), |
261 new_data_.size(), | 264 new_data_.size(), |
262 io_callback_, | 265 io_callback_, |
263 true /* truncate */); | 266 true /* truncate */); |
264 } | 267 } |
265 | 268 |
266 int DiskCacheBasedQuicServerInfo::DoCreateOrOpen() { | 269 int DiskCacheBasedQuicServerInfo::DoCreateOrOpen() { |
267 DCHECK(entry_ == NULL); | |
268 state_ = CREATE_OR_OPEN_COMPLETE; | 270 state_ = CREATE_OR_OPEN_COMPLETE; |
271 if (entry_) | |
272 return OK; | |
273 | |
269 if (found_entry_) { | 274 if (found_entry_) { |
270 return backend_->OpenEntry(key(), &data_shim_->entry, io_callback_); | 275 return backend_->OpenEntry(key(), &data_shim_->entry, io_callback_); |
271 } | 276 } |
272 | 277 |
273 return backend_->CreateEntry(key(), &data_shim_->entry, io_callback_); | 278 return backend_->CreateEntry(key(), &data_shim_->entry, io_callback_); |
274 } | 279 } |
275 | 280 |
276 int DiskCacheBasedQuicServerInfo::DoWaitForDataReadyDone() { | 281 int DiskCacheBasedQuicServerInfo::DoWaitForDataReadyDone() { |
277 DCHECK(!ready_); | 282 DCHECK(!ready_); |
278 state_ = NONE; | 283 state_ = NONE; |
(...skipping 10 matching lines...) Expand all Loading... | |
289 int DiskCacheBasedQuicServerInfo::DoSetDone() { | 294 int DiskCacheBasedQuicServerInfo::DoSetDone() { |
290 if (entry_) | 295 if (entry_) |
291 entry_->Close(); | 296 entry_->Close(); |
292 entry_ = NULL; | 297 entry_ = NULL; |
293 new_data_.clear(); | 298 new_data_.clear(); |
294 state_ = NONE; | 299 state_ = NONE; |
295 return OK; | 300 return OK; |
296 } | 301 } |
297 | 302 |
298 } // namespace net | 303 } // namespace net |
OLD | NEW |