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

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

Issue 192583004: QUIC - use QuicSessionKey tuple (host, port, is_https) instead of server_hostname (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with TOT Created 6 years, 9 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
OLDNEW
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"
11 #include "net/base/io_buffer.h" 11 #include "net/base/io_buffer.h"
12 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
13 #include "net/http/http_cache.h" 13 #include "net/http/http_cache.h"
14 #include "net/http/http_network_session.h" 14 #include "net/http/http_network_session.h"
15 #include "net/quic/quic_session_key.h"
15 16
16 namespace net { 17 namespace net {
17 18
18 // Some APIs inside disk_cache take a handle that the caller must keep alive 19 // Some APIs inside disk_cache take a handle that the caller must keep alive
19 // until the API has finished its asynchronous execution. 20 // until the API has finished its asynchronous execution.
20 // 21 //
21 // Unfortunately, DiskCacheBasedQuicServerInfo may be deleted before the 22 // Unfortunately, DiskCacheBasedQuicServerInfo may be deleted before the
22 // operation completes causing a use-after-free. 23 // operation completes causing a use-after-free.
23 // 24 //
24 // This data shim struct is meant to provide a location for the disk_cache 25 // This data shim struct is meant to provide a location for the disk_cache
(...skipping 11 matching lines...) Expand all
36 // 37 //
37 // TODO(ajwong): Change disk_cache's API to return results via Callback. 38 // TODO(ajwong): Change disk_cache's API to return results via Callback.
38 struct DiskCacheBasedQuicServerInfo::CacheOperationDataShim { 39 struct DiskCacheBasedQuicServerInfo::CacheOperationDataShim {
39 CacheOperationDataShim() : backend(NULL), entry(NULL) {} 40 CacheOperationDataShim() : backend(NULL), entry(NULL) {}
40 41
41 disk_cache::Backend* backend; 42 disk_cache::Backend* backend;
42 disk_cache::Entry* entry; 43 disk_cache::Entry* entry;
43 }; 44 };
44 45
45 DiskCacheBasedQuicServerInfo::DiskCacheBasedQuicServerInfo( 46 DiskCacheBasedQuicServerInfo::DiskCacheBasedQuicServerInfo(
46 const std::string& hostname, 47 const QuicSessionKey& server_key,
47 HttpCache* http_cache) 48 HttpCache* http_cache)
48 : QuicServerInfo(hostname), 49 : QuicServerInfo(server_key),
49 weak_factory_(this), 50 weak_factory_(this),
50 data_shim_(new CacheOperationDataShim()), 51 data_shim_(new CacheOperationDataShim()),
51 io_callback_( 52 io_callback_(
52 base::Bind(&DiskCacheBasedQuicServerInfo::OnIOComplete, 53 base::Bind(&DiskCacheBasedQuicServerInfo::OnIOComplete,
53 weak_factory_.GetWeakPtr(), 54 weak_factory_.GetWeakPtr(),
54 base::Owned(data_shim_))), // Ownership assigned. 55 base::Owned(data_shim_))), // Ownership assigned.
55 state_(GET_BACKEND), 56 state_(GET_BACKEND),
56 ready_(false), 57 ready_(false),
57 found_entry_(false), 58 found_entry_(false),
58 hostname_(hostname), 59 server_key_(server_key),
59 http_cache_(http_cache), 60 http_cache_(http_cache),
60 backend_(NULL), 61 backend_(NULL),
61 entry_(NULL) { 62 entry_(NULL) {
62 } 63 }
63 64
64 void DiskCacheBasedQuicServerInfo::Start() { 65 void DiskCacheBasedQuicServerInfo::Start() {
65 DCHECK(CalledOnValidThread()); 66 DCHECK(CalledOnValidThread());
66 DCHECK_EQ(GET_BACKEND, state_); 67 DCHECK_EQ(GET_BACKEND, state_);
67 DoLoop(OK); 68 DoLoop(OK);
68 } 69 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 DoLoop(OK); 107 DoLoop(OK);
107 } 108 }
108 109
109 DiskCacheBasedQuicServerInfo::~DiskCacheBasedQuicServerInfo() { 110 DiskCacheBasedQuicServerInfo::~DiskCacheBasedQuicServerInfo() {
110 DCHECK(user_callback_.is_null()); 111 DCHECK(user_callback_.is_null());
111 if (entry_) 112 if (entry_)
112 entry_->Close(); 113 entry_->Close();
113 } 114 }
114 115
115 std::string DiskCacheBasedQuicServerInfo::key() const { 116 std::string DiskCacheBasedQuicServerInfo::key() const {
116 return "quicserverinfo:" + hostname_; 117 return "quicserverinfo:" + server_key_.ToString();
117 } 118 }
118 119
119 void DiskCacheBasedQuicServerInfo::OnIOComplete(CacheOperationDataShim* unused, 120 void DiskCacheBasedQuicServerInfo::OnIOComplete(CacheOperationDataShim* unused,
120 int rv) { 121 int rv) {
121 DCHECK_NE(NONE, state_); 122 DCHECK_NE(NONE, state_);
122 rv = DoLoop(rv); 123 rv = DoLoop(rv);
123 if (rv != ERR_IO_PENDING && !user_callback_.is_null()) { 124 if (rv != ERR_IO_PENDING && !user_callback_.is_null()) {
124 CompletionCallback callback = user_callback_; 125 CompletionCallback callback = user_callback_;
125 user_callback_.Reset(); 126 user_callback_.Reset();
126 callback.Run(rv); 127 callback.Run(rv);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 int DiskCacheBasedQuicServerInfo::DoSetDone() { 280 int DiskCacheBasedQuicServerInfo::DoSetDone() {
280 if (entry_) 281 if (entry_)
281 entry_->Close(); 282 entry_->Close();
282 entry_ = NULL; 283 entry_ = NULL;
283 new_data_.clear(); 284 new_data_.clear();
284 state_ = NONE; 285 state_ = NONE;
285 return OK; 286 return OK;
286 } 287 }
287 288
288 } // namespace net 289 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698