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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 int DiskCacheBasedQuicServerInfo::DoRead() { | 240 int DiskCacheBasedQuicServerInfo::DoRead() { |
241 const int32 size = entry_->GetDataSize(0 /* index */); | 241 const int32 size = entry_->GetDataSize(0 /* index */); |
242 if (!size) { | 242 if (!size) { |
243 state_ = WAIT_FOR_DATA_READY_DONE; | 243 state_ = WAIT_FOR_DATA_READY_DONE; |
244 return OK; | 244 return OK; |
245 } | 245 } |
246 | 246 |
247 read_buffer_ = new IOBuffer(size); | 247 read_buffer_ = new IOBuffer(size); |
248 state_ = READ_COMPLETE; | 248 state_ = READ_COMPLETE; |
249 return entry_->ReadData( | 249 return entry_->ReadData( |
250 0 /* index */, 0 /* offset */, read_buffer_, size, io_callback_); | 250 0 /* index */, 0 /* offset */, read_buffer_.get(), size, io_callback_); |
251 } | 251 } |
252 | 252 |
253 int DiskCacheBasedQuicServerInfo::DoWrite() { | 253 int DiskCacheBasedQuicServerInfo::DoWrite() { |
254 write_buffer_ = new IOBuffer(new_data_.size()); | 254 write_buffer_ = new IOBuffer(new_data_.size()); |
255 memcpy(write_buffer_->data(), new_data_.data(), new_data_.size()); | 255 memcpy(write_buffer_->data(), new_data_.data(), new_data_.size()); |
256 state_ = WRITE_COMPLETE; | 256 state_ = WRITE_COMPLETE; |
257 | 257 |
258 return entry_->WriteData( | 258 return entry_->WriteData(0 /* index */, |
259 0 /* index */, 0 /* offset */, write_buffer_, new_data_.size(), | 259 0 /* offset */, |
260 io_callback_, true /* truncate */); | 260 write_buffer_.get(), |
| 261 new_data_.size(), |
| 262 io_callback_, |
| 263 true /* truncate */); |
261 } | 264 } |
262 | 265 |
263 int DiskCacheBasedQuicServerInfo::DoCreateOrOpen() { | 266 int DiskCacheBasedQuicServerInfo::DoCreateOrOpen() { |
264 DCHECK(entry_ == NULL); | 267 DCHECK(entry_ == NULL); |
265 state_ = CREATE_OR_OPEN_COMPLETE; | 268 state_ = CREATE_OR_OPEN_COMPLETE; |
266 if (found_entry_) { | 269 if (found_entry_) { |
267 return backend_->OpenEntry(key(), &data_shim_->entry, io_callback_); | 270 return backend_->OpenEntry(key(), &data_shim_->entry, io_callback_); |
268 } | 271 } |
269 | 272 |
270 return backend_->CreateEntry(key(), &data_shim_->entry, io_callback_); | 273 return backend_->CreateEntry(key(), &data_shim_->entry, io_callback_); |
(...skipping 15 matching lines...) Expand all Loading... |
286 int DiskCacheBasedQuicServerInfo::DoSetDone() { | 289 int DiskCacheBasedQuicServerInfo::DoSetDone() { |
287 if (entry_) | 290 if (entry_) |
288 entry_->Close(); | 291 entry_->Close(); |
289 entry_ = NULL; | 292 entry_ = NULL; |
290 new_data_.clear(); | 293 new_data_.clear(); |
291 state_ = NONE; | 294 state_ = NONE; |
292 return OK; | 295 return OK; |
293 } | 296 } |
294 | 297 |
295 } // namespace net | 298 } // namespace net |
OLD | NEW |