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

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

Issue 1062413002: Remove unnecessary instrumentation for several jank bugs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile fixes Created 5 years, 8 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
« no previous file with comments | « net/http/disk_based_cert_cache.cc ('k') | net/http/http_auth_handler_negotiate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/profiler/scoped_tracker.h"
13 #include "net/base/completion_callback.h" 12 #include "net/base/completion_callback.h"
14 #include "net/base/io_buffer.h" 13 #include "net/base/io_buffer.h"
15 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
16 #include "net/http/http_cache.h" 15 #include "net/http/http_cache.h"
17 #include "net/http/http_network_session.h" 16 #include "net/http/http_network_session.h"
18 #include "net/quic/quic_server_id.h" 17 #include "net/quic/quic_server_id.h"
19 18
20 namespace net { 19 namespace net {
21 20
22 // Some APIs inside disk_cache take a handle that the caller must keep alive 21 // Some APIs inside disk_cache take a handle that the caller must keep alive
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // Handle updates while a write is pending or if we haven't loaded from disk 135 // Handle updates while a write is pending or if we haven't loaded from disk
137 // cache. Save the data to be written into a temporary buffer and then 136 // cache. Save the data to be written into a temporary buffer and then
138 // persist that data when we are ready to persist. 137 // persist that data when we are ready to persist.
139 pending_write_data_ = Serialize(); 138 pending_write_data_ = Serialize();
140 return; 139 return;
141 } 140 }
142 PersistInternal(); 141 PersistInternal();
143 } 142 }
144 143
145 void DiskCacheBasedQuicServerInfo::PersistInternal() { 144 void DiskCacheBasedQuicServerInfo::PersistInternal() {
146 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
147 tracked_objects::ScopedTracker tracking_profile(
148 FROM_HERE_WITH_EXPLICIT_FUNCTION(
149 "422516 DiskCacheBasedQuicServerInfo::PersistInternal"));
150
151 DCHECK(CalledOnValidThread()); 145 DCHECK(CalledOnValidThread());
152 DCHECK_NE(GET_BACKEND, state_); 146 DCHECK_NE(GET_BACKEND, state_);
153 DCHECK(new_data_.empty()); 147 DCHECK(new_data_.empty());
154 CHECK(ready_); 148 CHECK(ready_);
155 DCHECK(wait_for_ready_callback_.is_null()); 149 DCHECK(wait_for_ready_callback_.is_null());
156 150
157 if (pending_write_data_.empty()) { 151 if (pending_write_data_.empty()) {
158 new_data_ = Serialize(); 152 new_data_ = Serialize();
159 } else { 153 } else {
160 new_data_ = pending_write_data_; 154 new_data_ = pending_write_data_;
(...skipping 28 matching lines...) Expand all
189 if (entry_) 183 if (entry_)
190 entry_->Close(); 184 entry_->Close();
191 } 185 }
192 186
193 std::string DiskCacheBasedQuicServerInfo::key() const { 187 std::string DiskCacheBasedQuicServerInfo::key() const {
194 return "quicserverinfo:" + server_id_.ToString(); 188 return "quicserverinfo:" + server_id_.ToString();
195 } 189 }
196 190
197 void DiskCacheBasedQuicServerInfo::OnIOComplete(CacheOperationDataShim* unused, 191 void DiskCacheBasedQuicServerInfo::OnIOComplete(CacheOperationDataShim* unused,
198 int rv) { 192 int rv) {
199 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
200 tracked_objects::ScopedTracker tracking_profile(
201 FROM_HERE_WITH_EXPLICIT_FUNCTION(
202 "422516 DiskCacheBasedQuicServerInfo::OnIOComplete"));
203
204 DCHECK_NE(NONE, state_); 193 DCHECK_NE(NONE, state_);
205 rv = DoLoop(rv); 194 rv = DoLoop(rv);
206 if (rv == ERR_IO_PENDING) 195 if (rv == ERR_IO_PENDING)
207 return; 196 return;
208 197
209 base::WeakPtr<DiskCacheBasedQuicServerInfo> weak_this = 198 base::WeakPtr<DiskCacheBasedQuicServerInfo> weak_this =
210 weak_factory_.GetWeakPtr(); 199 weak_factory_.GetWeakPtr();
211 200
212 if (!wait_for_ready_callback_.is_null()) { 201 if (!wait_for_ready_callback_.is_null()) {
213 wait_for_data_end_time_ = base::TimeTicks::Now(); 202 wait_for_data_end_time_ = base::TimeTicks::Now();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 default: 253 default:
265 rv = OK; 254 rv = OK;
266 NOTREACHED(); 255 NOTREACHED();
267 } 256 }
268 } while (rv != ERR_IO_PENDING && state_ != NONE); 257 } while (rv != ERR_IO_PENDING && state_ != NONE);
269 258
270 return rv; 259 return rv;
271 } 260 }
272 261
273 int DiskCacheBasedQuicServerInfo::DoGetBackendComplete(int rv) { 262 int DiskCacheBasedQuicServerInfo::DoGetBackendComplete(int rv) {
274 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
275 tracked_objects::ScopedTracker tracking_profile(
276 FROM_HERE_WITH_EXPLICIT_FUNCTION(
277 "422516 DiskCacheBasedQuicServerInfo::DoGetBackendComplete"));
278
279 if (rv == OK) { 263 if (rv == OK) {
280 backend_ = data_shim_->backend; 264 backend_ = data_shim_->backend;
281 state_ = OPEN; 265 state_ = OPEN;
282 } else { 266 } else {
283 RecordQuicServerInfoFailure(GET_BACKEND_FAILURE); 267 RecordQuicServerInfoFailure(GET_BACKEND_FAILURE);
284 state_ = WAIT_FOR_DATA_READY_DONE; 268 state_ = WAIT_FOR_DATA_READY_DONE;
285 } 269 }
286 return OK; 270 return OK;
287 } 271 }
288 272
289 int DiskCacheBasedQuicServerInfo::DoOpenComplete(int rv) { 273 int DiskCacheBasedQuicServerInfo::DoOpenComplete(int rv) {
290 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
291 tracked_objects::ScopedTracker tracking_profile(
292 FROM_HERE_WITH_EXPLICIT_FUNCTION(
293 "422516 DiskCacheBasedQuicServerInfo::DoOpenComplete"));
294
295 if (rv == OK) { 274 if (rv == OK) {
296 entry_ = data_shim_->entry; 275 entry_ = data_shim_->entry;
297 state_ = READ; 276 state_ = READ;
298 found_entry_ = true; 277 found_entry_ = true;
299 } else { 278 } else {
300 RecordQuicServerInfoFailure(OPEN_FAILURE); 279 RecordQuicServerInfoFailure(OPEN_FAILURE);
301 state_ = WAIT_FOR_DATA_READY_DONE; 280 state_ = WAIT_FOR_DATA_READY_DONE;
302 } 281 }
303 282
304 return OK; 283 return OK;
305 } 284 }
306 285
307 int DiskCacheBasedQuicServerInfo::DoReadComplete(int rv) { 286 int DiskCacheBasedQuicServerInfo::DoReadComplete(int rv) {
308 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
309 tracked_objects::ScopedTracker tracking_profile(
310 FROM_HERE_WITH_EXPLICIT_FUNCTION(
311 "422516 DiskCacheBasedQuicServerInfo::DoReadComplete"));
312
313 if (rv > 0) 287 if (rv > 0)
314 data_.assign(read_buffer_->data(), rv); 288 data_.assign(read_buffer_->data(), rv);
315 else if (rv < 0) 289 else if (rv < 0)
316 RecordQuicServerInfoFailure(READ_FAILURE); 290 RecordQuicServerInfoFailure(READ_FAILURE);
317 291
318 state_ = WAIT_FOR_DATA_READY_DONE; 292 state_ = WAIT_FOR_DATA_READY_DONE;
319 return OK; 293 return OK;
320 } 294 }
321 295
322 int DiskCacheBasedQuicServerInfo::DoWriteComplete(int rv) { 296 int DiskCacheBasedQuicServerInfo::DoWriteComplete(int rv) {
323 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
324 tracked_objects::ScopedTracker tracking_profile(
325 FROM_HERE_WITH_EXPLICIT_FUNCTION(
326 "422516 DiskCacheBasedQuicServerInfo::DoWriteComplete"));
327
328 if (rv < 0) 297 if (rv < 0)
329 RecordQuicServerInfoFailure(WRITE_FAILURE); 298 RecordQuicServerInfoFailure(WRITE_FAILURE);
330 state_ = SET_DONE; 299 state_ = SET_DONE;
331 return OK; 300 return OK;
332 } 301 }
333 302
334 int DiskCacheBasedQuicServerInfo::DoCreateOrOpenComplete(int rv) { 303 int DiskCacheBasedQuicServerInfo::DoCreateOrOpenComplete(int rv) {
335 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
336 tracked_objects::ScopedTracker tracking_profile(
337 FROM_HERE_WITH_EXPLICIT_FUNCTION(
338 "422516 DiskCacheBasedQuicServerInfo::DoCreateOrOpenComplete"));
339
340 if (rv != OK) { 304 if (rv != OK) {
341 RecordQuicServerInfoFailure(CREATE_OR_OPEN_FAILURE); 305 RecordQuicServerInfoFailure(CREATE_OR_OPEN_FAILURE);
342 state_ = SET_DONE; 306 state_ = SET_DONE;
343 } else { 307 } else {
344 if (!entry_) { 308 if (!entry_) {
345 entry_ = data_shim_->entry; 309 entry_ = data_shim_->entry;
346 found_entry_ = true; 310 found_entry_ = true;
347 } 311 }
348 DCHECK(entry_); 312 DCHECK(entry_);
349 state_ = WRITE; 313 state_ = WRITE;
350 } 314 }
351 return OK; 315 return OK;
352 } 316 }
353 317
354 int DiskCacheBasedQuicServerInfo::DoGetBackend() { 318 int DiskCacheBasedQuicServerInfo::DoGetBackend() {
355 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
356 tracked_objects::ScopedTracker tracking_profile(
357 FROM_HERE_WITH_EXPLICIT_FUNCTION(
358 "422516 DiskCacheBasedQuicServerInfo::DoGetBackend"));
359
360 state_ = GET_BACKEND_COMPLETE; 319 state_ = GET_BACKEND_COMPLETE;
361 return http_cache_->GetBackend(&data_shim_->backend, io_callback_); 320 return http_cache_->GetBackend(&data_shim_->backend, io_callback_);
362 } 321 }
363 322
364 int DiskCacheBasedQuicServerInfo::DoOpen() { 323 int DiskCacheBasedQuicServerInfo::DoOpen() {
365 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
366 tracked_objects::ScopedTracker tracking_profile(
367 FROM_HERE_WITH_EXPLICIT_FUNCTION(
368 "422516 DiskCacheBasedQuicServerInfo::DoOpen"));
369
370 state_ = OPEN_COMPLETE; 324 state_ = OPEN_COMPLETE;
371 return backend_->OpenEntry(key(), &data_shim_->entry, io_callback_); 325 return backend_->OpenEntry(key(), &data_shim_->entry, io_callback_);
372 } 326 }
373 327
374 int DiskCacheBasedQuicServerInfo::DoRead() { 328 int DiskCacheBasedQuicServerInfo::DoRead() {
375 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
376 tracked_objects::ScopedTracker tracking_profile(
377 FROM_HERE_WITH_EXPLICIT_FUNCTION(
378 "422516 DiskCacheBasedQuicServerInfo::DoRead"));
379
380 const int32 size = entry_->GetDataSize(0 /* index */); 329 const int32 size = entry_->GetDataSize(0 /* index */);
381 if (!size) { 330 if (!size) {
382 state_ = WAIT_FOR_DATA_READY_DONE; 331 state_ = WAIT_FOR_DATA_READY_DONE;
383 return OK; 332 return OK;
384 } 333 }
385 334
386 read_buffer_ = new IOBuffer(size); 335 read_buffer_ = new IOBuffer(size);
387 state_ = READ_COMPLETE; 336 state_ = READ_COMPLETE;
388 return entry_->ReadData( 337 return entry_->ReadData(
389 0 /* index */, 0 /* offset */, read_buffer_.get(), size, io_callback_); 338 0 /* index */, 0 /* offset */, read_buffer_.get(), size, io_callback_);
390 } 339 }
391 340
392 int DiskCacheBasedQuicServerInfo::DoWrite() { 341 int DiskCacheBasedQuicServerInfo::DoWrite() {
393 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
394 tracked_objects::ScopedTracker tracking_profile(
395 FROM_HERE_WITH_EXPLICIT_FUNCTION(
396 "422516 DiskCacheBasedQuicServerInfo::DoWrite"));
397
398 write_buffer_ = new IOBuffer(new_data_.size()); 342 write_buffer_ = new IOBuffer(new_data_.size());
399 memcpy(write_buffer_->data(), new_data_.data(), new_data_.size()); 343 memcpy(write_buffer_->data(), new_data_.data(), new_data_.size());
400 state_ = WRITE_COMPLETE; 344 state_ = WRITE_COMPLETE;
401 345
402 return entry_->WriteData(0 /* index */, 346 return entry_->WriteData(0 /* index */,
403 0 /* offset */, 347 0 /* offset */,
404 write_buffer_.get(), 348 write_buffer_.get(),
405 new_data_.size(), 349 new_data_.size(),
406 io_callback_, 350 io_callback_,
407 true /* truncate */); 351 true /* truncate */);
408 } 352 }
409 353
410 int DiskCacheBasedQuicServerInfo::DoCreateOrOpen() { 354 int DiskCacheBasedQuicServerInfo::DoCreateOrOpen() {
411 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
412 tracked_objects::ScopedTracker tracking_profile(
413 FROM_HERE_WITH_EXPLICIT_FUNCTION(
414 "422516 DiskCacheBasedQuicServerInfo::DoCreateOrOpen"));
415
416 state_ = CREATE_OR_OPEN_COMPLETE; 355 state_ = CREATE_OR_OPEN_COMPLETE;
417 if (entry_) 356 if (entry_)
418 return OK; 357 return OK;
419 358
420 if (found_entry_) { 359 if (found_entry_) {
421 return backend_->OpenEntry(key(), &data_shim_->entry, io_callback_); 360 return backend_->OpenEntry(key(), &data_shim_->entry, io_callback_);
422 } 361 }
423 362
424 return backend_->CreateEntry(key(), &data_shim_->entry, io_callback_); 363 return backend_->CreateEntry(key(), &data_shim_->entry, io_callback_);
425 } 364 }
426 365
427 int DiskCacheBasedQuicServerInfo::DoWaitForDataReadyDone() { 366 int DiskCacheBasedQuicServerInfo::DoWaitForDataReadyDone() {
428 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422516 is fixed.
429 tracked_objects::ScopedTracker tracking_profile(
430 FROM_HERE_WITH_EXPLICIT_FUNCTION(
431 "422516 DiskCacheBasedQuicServerInfo::DoWaitForDataReadyDone"));
432
433 DCHECK(!ready_); 367 DCHECK(!ready_);
434 state_ = NONE; 368 state_ = NONE;
435 ready_ = true; 369 ready_ = true;
436 // We close the entry because, if we shutdown before ::Persist is called, 370 // We close the entry because, if we shutdown before ::Persist is called,
437 // then we might leak a cache reference, which causes a DCHECK on shutdown. 371 // then we might leak a cache reference, which causes a DCHECK on shutdown.
438 if (entry_) 372 if (entry_)
439 entry_->Close(); 373 entry_->Close();
440 entry_ = NULL; 374 entry_ = NULL;
441 375
442 RecordQuicServerInfoStatus(QUIC_SERVER_INFO_PARSE); 376 RecordQuicServerInfoStatus(QUIC_SERVER_INFO_PARSE);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 } else if (backend_->GetCacheType() == net::MEMORY_CACHE) { 428 } else if (backend_->GetCacheType() == net::MEMORY_CACHE) {
495 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.FailureReason.MemoryCache", 429 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.FailureReason.MemoryCache",
496 failure, NUM_OF_FAILURES); 430 failure, NUM_OF_FAILURES);
497 } else { 431 } else {
498 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.FailureReason.DiskCache", 432 UMA_HISTOGRAM_ENUMERATION("Net.QuicDiskCache.FailureReason.DiskCache",
499 failure, NUM_OF_FAILURES); 433 failure, NUM_OF_FAILURES);
500 } 434 }
501 } 435 }
502 436
503 } // namespace net 437 } // namespace net
OLDNEW
« no previous file with comments | « net/http/disk_based_cert_cache.cc ('k') | net/http/http_auth_handler_negotiate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698