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

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: 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 "base/strings/string_number_conversions.h"
10 #include "net/base/completion_callback.h" 11 #include "net/base/completion_callback.h"
11 #include "net/base/io_buffer.h" 12 #include "net/base/io_buffer.h"
12 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
13 #include "net/http/http_cache.h" 14 #include "net/http/http_cache.h"
14 #include "net/http/http_network_session.h" 15 #include "net/http/http_network_session.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.
(...skipping 17 matching lines...) Expand all
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 std::string& hostname,
48 uint16 port,
47 HttpCache* http_cache) 49 HttpCache* http_cache)
48 : QuicServerInfo(hostname), 50 : QuicServerInfo(hostname, port),
49 weak_factory_(this), 51 weak_factory_(this),
50 data_shim_(new CacheOperationDataShim()), 52 data_shim_(new CacheOperationDataShim()),
51 io_callback_( 53 io_callback_(
52 base::Bind(&DiskCacheBasedQuicServerInfo::OnIOComplete, 54 base::Bind(&DiskCacheBasedQuicServerInfo::OnIOComplete,
53 weak_factory_.GetWeakPtr(), 55 weak_factory_.GetWeakPtr(),
54 base::Owned(data_shim_))), // Ownership assigned. 56 base::Owned(data_shim_))), // Ownership assigned.
55 state_(GET_BACKEND), 57 state_(GET_BACKEND),
56 ready_(false), 58 ready_(false),
57 found_entry_(false), 59 found_entry_(false),
58 hostname_(hostname), 60 hostname_(hostname),
61 port_(port),
59 http_cache_(http_cache), 62 http_cache_(http_cache),
60 backend_(NULL), 63 backend_(NULL),
61 entry_(NULL) { 64 entry_(NULL) {
62 } 65 }
63 66
64 void DiskCacheBasedQuicServerInfo::Start() { 67 void DiskCacheBasedQuicServerInfo::Start() {
65 DCHECK(CalledOnValidThread()); 68 DCHECK(CalledOnValidThread());
66 DCHECK_EQ(GET_BACKEND, state_); 69 DCHECK_EQ(GET_BACKEND, state_);
67 DoLoop(OK); 70 DoLoop(OK);
68 } 71 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 DoLoop(OK); 109 DoLoop(OK);
107 } 110 }
108 111
109 DiskCacheBasedQuicServerInfo::~DiskCacheBasedQuicServerInfo() { 112 DiskCacheBasedQuicServerInfo::~DiskCacheBasedQuicServerInfo() {
110 DCHECK(user_callback_.is_null()); 113 DCHECK(user_callback_.is_null());
111 if (entry_) 114 if (entry_)
112 entry_->Close(); 115 entry_->Close();
113 } 116 }
114 117
115 std::string DiskCacheBasedQuicServerInfo::key() const { 118 std::string DiskCacheBasedQuicServerInfo::key() const {
116 return "quicserverinfo:" + hostname_; 119 return "quicserverinfo:" + hostname_ + "/" + base::UintToString(port_);
Ryan Hamilton 2014/03/10 20:57:33 nit: what do you think about ":" instead of "/"?
ramant (doing other things) 2014/03/11 00:48:50 Done.
117 } 120 }
118 121
119 void DiskCacheBasedQuicServerInfo::OnIOComplete(CacheOperationDataShim* unused, 122 void DiskCacheBasedQuicServerInfo::OnIOComplete(CacheOperationDataShim* unused,
120 int rv) { 123 int rv) {
121 DCHECK_NE(NONE, state_); 124 DCHECK_NE(NONE, state_);
122 rv = DoLoop(rv); 125 rv = DoLoop(rv);
123 if (rv != ERR_IO_PENDING && !user_callback_.is_null()) { 126 if (rv != ERR_IO_PENDING && !user_callback_.is_null()) {
124 CompletionCallback callback = user_callback_; 127 CompletionCallback callback = user_callback_;
125 user_callback_.Reset(); 128 user_callback_.Reset();
126 callback.Run(rv); 129 callback.Run(rv);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 int DiskCacheBasedQuicServerInfo::DoSetDone() { 282 int DiskCacheBasedQuicServerInfo::DoSetDone() {
280 if (entry_) 283 if (entry_)
281 entry_->Close(); 284 entry_->Close();
282 entry_ = NULL; 285 entry_ = NULL;
283 new_data_.clear(); 286 new_data_.clear();
284 state_ = NONE; 287 state_ = NONE;
285 return OK; 288 return OK;
286 } 289 }
287 290
288 } // namespace net 291 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698