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

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

Issue 154933003: Persist server's crypto config data to disk cache for 0-RTT (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comments for Patch Set 4 Created 6 years, 10 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"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 void DiskCacheBasedQuicServerInfo::Start() { 64 void DiskCacheBasedQuicServerInfo::Start() {
65 DCHECK(CalledOnValidThread()); 65 DCHECK(CalledOnValidThread());
66 DCHECK_EQ(GET_BACKEND, state_); 66 DCHECK_EQ(GET_BACKEND, state_);
67 DoLoop(OK); 67 DoLoop(OK);
68 } 68 }
69 69
70 int DiskCacheBasedQuicServerInfo::WaitForDataReady( 70 int DiskCacheBasedQuicServerInfo::WaitForDataReady(
71 const CompletionCallback& callback) { 71 const CompletionCallback& callback) {
72 DCHECK(CalledOnValidThread()); 72 DCHECK(CalledOnValidThread());
73 DCHECK(state_ != GET_BACKEND); 73 DCHECK_NE(GET_BACKEND, state_);
74 74
75 if (ready_) 75 if (ready_)
76 return OK; 76 return OK;
77 77
78 if (!callback.is_null()) { 78 if (!callback.is_null()) {
79 DCHECK(user_callback_.is_null()); 79 // Prevent a new callback for WaitForDataReady overwriting an existing
80 // pending callback(|user_callback_|).
wtc 2014/02/13 23:48:43 Nit: add a space before the opening parenthesis '(
ramant (doing other things) 2014/02/15 00:36:12 Done.
81 if (!user_callback_.is_null())
82 return ERR_INVALID_ARGUMENT;
80 user_callback_ = callback; 83 user_callback_ = callback;
81 } 84 }
82 85
83 return ERR_IO_PENDING; 86 return ERR_IO_PENDING;
84 } 87 }
85 88
89 bool DiskCacheBasedQuicServerInfo::IsDataReady() {
90 return ready_;
91 }
92
86 void DiskCacheBasedQuicServerInfo::Persist() { 93 void DiskCacheBasedQuicServerInfo::Persist() {
87 DCHECK(CalledOnValidThread()); 94 DCHECK(CalledOnValidThread());
88 DCHECK(state_ != GET_BACKEND); 95 DCHECK_NE(GET_BACKEND, state_);
89 96
90 DCHECK(new_data_.empty()); 97 DCHECK(new_data_.empty());
91 CHECK(ready_); 98 CHECK(ready_);
92 DCHECK(user_callback_.is_null()); 99 DCHECK(user_callback_.is_null());
93 new_data_ = Serialize(); 100 new_data_ = Serialize();
94 101
95 if (!backend_) 102 if (!backend_)
96 return; 103 return;
97 104
98 state_ = CREATE_OR_OPEN; 105 state_ = CREATE_OR_OPEN;
99 DoLoop(OK); 106 DoLoop(OK);
100 } 107 }
101 108
102 DiskCacheBasedQuicServerInfo::~DiskCacheBasedQuicServerInfo() { 109 DiskCacheBasedQuicServerInfo::~DiskCacheBasedQuicServerInfo() {
103 DCHECK(user_callback_.is_null()); 110 DCHECK(user_callback_.is_null());
104 if (entry_) 111 if (entry_)
105 entry_->Close(); 112 entry_->Close();
106 } 113 }
107 114
108 std::string DiskCacheBasedQuicServerInfo::key() const { 115 std::string DiskCacheBasedQuicServerInfo::key() const {
109 return "quicserverinfo:" + hostname_; 116 return "quicserverinfo:" + hostname_;
110 } 117 }
111 118
112 void DiskCacheBasedQuicServerInfo::OnIOComplete(CacheOperationDataShim* unused, 119 void DiskCacheBasedQuicServerInfo::OnIOComplete(CacheOperationDataShim* unused,
113 int rv) { 120 int rv) {
121 DCHECK_NE(NONE, state_);
114 rv = DoLoop(rv); 122 rv = DoLoop(rv);
115 if (rv != ERR_IO_PENDING && !user_callback_.is_null()) { 123 if (rv != ERR_IO_PENDING && !user_callback_.is_null()) {
116 CompletionCallback callback = user_callback_; 124 CompletionCallback callback = user_callback_;
117 user_callback_.Reset(); 125 user_callback_.Reset();
118 callback.Run(rv); 126 callback.Run(rv);
119 } 127 }
120 } 128 }
121 129
122 int DiskCacheBasedQuicServerInfo::DoLoop(int rv) { 130 int DiskCacheBasedQuicServerInfo::DoLoop(int rv) {
123 do { 131 do {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 entry_->Close(); 273 entry_->Close();
266 entry_ = NULL; 274 entry_ = NULL;
267 Parse(data_); 275 Parse(data_);
268 return OK; 276 return OK;
269 } 277 }
270 278
271 int DiskCacheBasedQuicServerInfo::DoSetDone() { 279 int DiskCacheBasedQuicServerInfo::DoSetDone() {
272 if (entry_) 280 if (entry_)
273 entry_->Close(); 281 entry_->Close();
274 entry_ = NULL; 282 entry_ = NULL;
283 new_data_.clear();
275 state_ = NONE; 284 state_ = NONE;
276 return OK; 285 return OK;
277 } 286 }
278 287
279 } // namespace net 288 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698