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 29 matching lines...) Expand all Loading... |
40 CacheOperationDataShim() : backend(NULL), entry(NULL) {} | 40 CacheOperationDataShim() : backend(NULL), entry(NULL) {} |
41 | 41 |
42 disk_cache::Backend* backend; | 42 disk_cache::Backend* backend; |
43 disk_cache::Entry* entry; | 43 disk_cache::Entry* entry; |
44 }; | 44 }; |
45 | 45 |
46 DiskCacheBasedQuicServerInfo::DiskCacheBasedQuicServerInfo( | 46 DiskCacheBasedQuicServerInfo::DiskCacheBasedQuicServerInfo( |
47 const QuicServerId& server_id, | 47 const QuicServerId& server_id, |
48 HttpCache* http_cache) | 48 HttpCache* http_cache) |
49 : QuicServerInfo(server_id), | 49 : QuicServerInfo(server_id), |
50 weak_factory_(this), | |
51 data_shim_(new CacheOperationDataShim()), | 50 data_shim_(new CacheOperationDataShim()), |
52 io_callback_( | |
53 base::Bind(&DiskCacheBasedQuicServerInfo::OnIOComplete, | |
54 weak_factory_.GetWeakPtr(), | |
55 base::Owned(data_shim_))), // Ownership assigned. | |
56 state_(GET_BACKEND), | 51 state_(GET_BACKEND), |
57 ready_(false), | 52 ready_(false), |
58 found_entry_(false), | 53 found_entry_(false), |
59 server_id_(server_id), | 54 server_id_(server_id), |
60 http_cache_(http_cache), | 55 http_cache_(http_cache), |
61 backend_(NULL), | 56 backend_(NULL), |
62 entry_(NULL) { | 57 entry_(NULL), |
| 58 weak_factory_(this) { |
| 59 io_callback_ = |
| 60 base::Bind(&DiskCacheBasedQuicServerInfo::OnIOComplete, |
| 61 weak_factory_.GetWeakPtr(), |
| 62 base::Owned(data_shim_)); // Ownership assigned. |
63 } | 63 } |
64 | 64 |
65 void DiskCacheBasedQuicServerInfo::Start() { | 65 void DiskCacheBasedQuicServerInfo::Start() { |
66 DCHECK(CalledOnValidThread()); | 66 DCHECK(CalledOnValidThread()); |
67 DCHECK_EQ(GET_BACKEND, state_); | 67 DCHECK_EQ(GET_BACKEND, state_); |
68 DoLoop(OK); | 68 DoLoop(OK); |
69 } | 69 } |
70 | 70 |
71 int DiskCacheBasedQuicServerInfo::WaitForDataReady( | 71 int DiskCacheBasedQuicServerInfo::WaitForDataReady( |
72 const CompletionCallback& callback) { | 72 const CompletionCallback& callback) { |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 int DiskCacheBasedQuicServerInfo::DoSetDone() { | 286 int DiskCacheBasedQuicServerInfo::DoSetDone() { |
287 if (entry_) | 287 if (entry_) |
288 entry_->Close(); | 288 entry_->Close(); |
289 entry_ = NULL; | 289 entry_ = NULL; |
290 new_data_.clear(); | 290 new_data_.clear(); |
291 state_ = NONE; | 291 state_ = NONE; |
292 return OK; | 292 return OK; |
293 } | 293 } |
294 | 294 |
295 } // namespace net | 295 } // namespace net |
OLD | NEW |