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

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

Issue 1569673002: [NOT FOR LANDING] Detailed loading traces Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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
« no previous file with comments | « net/extras/sqlite/sqlite_persistent_cookie_store.cc ('k') | net/http/http_cache_transaction.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/http_cache.h" 5 #include "net/http/http_cache.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/trace_event/trace_event.h"
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
12 #include "base/callback.h" 13 #include "base/callback.h"
13 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
14 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
15 #include "base/format_macros.h" 16 #include "base/format_macros.h"
16 #include "base/location.h" 17 #include "base/location.h"
17 #include "base/macros.h" 18 #include "base/macros.h"
18 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
19 #include "base/metrics/field_trial.h" 20 #include "base/metrics/field_trial.h"
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 } 384 }
384 385
385 disk_cache::Backend* HttpCache::GetCurrentBackend() const { 386 disk_cache::Backend* HttpCache::GetCurrentBackend() const {
386 return disk_cache_.get(); 387 return disk_cache_.get();
387 } 388 }
388 389
389 // static 390 // static
390 bool HttpCache::ParseResponseInfo(const char* data, int len, 391 bool HttpCache::ParseResponseInfo(const char* data, int len,
391 HttpResponseInfo* response_info, 392 HttpResponseInfo* response_info,
392 bool* response_truncated) { 393 bool* response_truncated) {
394 TRACE_EVENT0("toplevel", "HttpCache::ParseResponseInfo");
393 base::Pickle pickle(data, len); 395 base::Pickle pickle(data, len);
394 return response_info->InitFromPickle(pickle, response_truncated); 396 return response_info->InitFromPickle(pickle, response_truncated);
395 } 397 }
396 398
397 void HttpCache::WriteMetadata(const GURL& url, 399 void HttpCache::WriteMetadata(const GURL& url,
398 RequestPriority priority, 400 RequestPriority priority,
399 base::Time expected_response_time, 401 base::Time expected_response_time,
400 IOBuffer* buf, 402 IOBuffer* buf,
401 int buf_len) { 403 int buf_len) {
402 if (!buf_len) 404 if (!buf_len)
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 } 712 }
711 } 713 }
712 } 714 }
713 DCHECK(pending_op->pending_queue.empty()); 715 DCHECK(pending_op->pending_queue.empty());
714 716
715 delete pending_op; 717 delete pending_op;
716 } 718 }
717 719
718 int HttpCache::OpenEntry(const std::string& key, ActiveEntry** entry, 720 int HttpCache::OpenEntry(const std::string& key, ActiveEntry** entry,
719 Transaction* trans) { 721 Transaction* trans) {
722 TRACE_EVENT0("toplevel", "HttpCache::OpenEntry::A");
720 ActiveEntry* active_entry = FindActiveEntry(key); 723 ActiveEntry* active_entry = FindActiveEntry(key);
721 if (active_entry) { 724 if (active_entry) {
722 *entry = active_entry; 725 *entry = active_entry;
723 return OK; 726 return OK;
724 } 727 }
728 TRACE_EVENT0("toplevel", "HttpCache::OpenEntry::B");
725 729
726 WorkItem* item = new WorkItem(WI_OPEN_ENTRY, trans, entry); 730 WorkItem* item = new WorkItem(WI_OPEN_ENTRY, trans, entry);
727 PendingOp* pending_op = GetPendingOp(key); 731 PendingOp* pending_op = GetPendingOp(key);
728 if (pending_op->writer) { 732 if (pending_op->writer) {
729 pending_op->pending_queue.push_back(item); 733 pending_op->pending_queue.push_back(item);
730 return ERR_IO_PENDING; 734 return ERR_IO_PENDING;
731 } 735 }
736 TRACE_EVENT0("toplevel", "HttpCache::OpenEntry::C");
732 737
733 DCHECK(pending_op->pending_queue.empty()); 738 DCHECK(pending_op->pending_queue.empty());
734 739
735 pending_op->writer = item; 740 pending_op->writer = item;
736 pending_op->callback = base::Bind(&HttpCache::OnPendingOpComplete, 741 pending_op->callback = base::Bind(&HttpCache::OnPendingOpComplete,
737 GetWeakPtr(), pending_op); 742 GetWeakPtr(), pending_op);
743 TRACE_EVENT0("toplevel", "HttpCache::OpenEntry::D");
738 744
739 int rv = disk_cache_->OpenEntry(key, &(pending_op->disk_entry), 745 int rv = disk_cache_->OpenEntry(key, &(pending_op->disk_entry),
740 pending_op->callback); 746 pending_op->callback);
747 TRACE_EVENT0("toplevel", "HttpCache::OpenEntry::E");
748
741 if (rv != ERR_IO_PENDING) { 749 if (rv != ERR_IO_PENDING) {
742 item->ClearTransaction(); 750 item->ClearTransaction();
743 pending_op->callback.Run(rv); 751 pending_op->callback.Run(rv);
744 } 752 }
745 753
746 return rv; 754 return rv;
747 } 755 }
748 756
749 int HttpCache::CreateEntry(const std::string& key, ActiveEntry** entry, 757 int HttpCache::CreateEntry(const std::string& key, ActiveEntry** entry,
750 Transaction* trans) { 758 Transaction* trans) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 // AddTransactionToEntry to add their transaction to the pending queue, which 825 // AddTransactionToEntry to add their transaction to the pending queue, which
818 // ensures FIFO ordering. 826 // ensures FIFO ordering.
819 if (!entry->writer && !entry->pending_queue.empty()) 827 if (!entry->writer && !entry->pending_queue.empty())
820 ProcessPendingQueue(entry); 828 ProcessPendingQueue(entry);
821 829
822 return OK; 830 return OK;
823 } 831 }
824 832
825 void HttpCache::DoneWithEntry(ActiveEntry* entry, Transaction* trans, 833 void HttpCache::DoneWithEntry(ActiveEntry* entry, Transaction* trans,
826 bool cancel) { 834 bool cancel) {
835 TRACE_EVENT0("toplevel", "HttpCache::DoneWithEntry");
827 // If we already posted a task to move on to the next transaction and this was 836 // If we already posted a task to move on to the next transaction and this was
828 // the writer, there is nothing to cancel. 837 // the writer, there is nothing to cancel.
829 if (entry->will_process_pending_queue && entry->readers.empty()) 838 if (entry->will_process_pending_queue && entry->readers.empty())
830 return; 839 return;
831 840
832 if (entry->writer) { 841 if (entry->writer) {
833 DCHECK(trans == entry->writer); 842 DCHECK(trans == entry->writer);
834 843
835 // Assume there was a failure. 844 // Assume there was a failure.
836 bool success = false; 845 bool success = false;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 // If this is really a pending transaction, and it is not part of 917 // If this is really a pending transaction, and it is not part of
909 // active_entries_, we should be creating the backend or the entry. 918 // active_entries_, we should be creating the backend or the entry.
910 return LOAD_STATE_WAITING_FOR_CACHE; 919 return LOAD_STATE_WAITING_FOR_CACHE;
911 } 920 }
912 921
913 Transaction* writer = i->second->writer; 922 Transaction* writer = i->second->writer;
914 return writer ? writer->GetWriterLoadState() : LOAD_STATE_WAITING_FOR_CACHE; 923 return writer ? writer->GetWriterLoadState() : LOAD_STATE_WAITING_FOR_CACHE;
915 } 924 }
916 925
917 void HttpCache::RemovePendingTransaction(Transaction* trans) { 926 void HttpCache::RemovePendingTransaction(Transaction* trans) {
927 TRACE_EVENT0("toplevel", "HttpCache::RemovePendingTransaction");
928
918 ActiveEntriesMap::const_iterator i = active_entries_.find(trans->key()); 929 ActiveEntriesMap::const_iterator i = active_entries_.find(trans->key());
919 bool found = false; 930 bool found = false;
920 if (i != active_entries_.end()) 931 if (i != active_entries_.end())
921 found = RemovePendingTransactionFromEntry(i->second, trans); 932 found = RemovePendingTransactionFromEntry(i->second, trans);
922 933
923 if (found) 934 if (found)
924 return; 935 return;
925 936
926 if (building_backend_) { 937 if (building_backend_) {
927 PendingOpsMap::const_iterator j = pending_ops_.find(std::string()); 938 PendingOpsMap::const_iterator j = pending_ops_.find(std::string());
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 building_backend_ = false; 1163 building_backend_ = false;
1153 DeletePendingOp(pending_op); 1164 DeletePendingOp(pending_op);
1154 } 1165 }
1155 1166
1156 // The cache may be gone when we return from the callback. 1167 // The cache may be gone when we return from the callback.
1157 if (!item->DoCallback(result, disk_cache_.get())) 1168 if (!item->DoCallback(result, disk_cache_.get()))
1158 item->NotifyTransaction(result, NULL); 1169 item->NotifyTransaction(result, NULL);
1159 } 1170 }
1160 1171
1161 } // namespace net 1172 } // namespace net
OLDNEW
« no previous file with comments | « net/extras/sqlite/sqlite_persistent_cookie_store.cc ('k') | net/http/http_cache_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698