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

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

Issue 10957045: Http Cache: Small adjustment to the logic that determines the reuse status of an entry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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
« no previous file with comments | « no previous file | no next file » | 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/infinite_cache.h" 5 #include "net/http/infinite_cache.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 REUSE_ALWAYS_EXPIRED, 862 REUSE_ALWAYS_EXPIRED,
863 REUSE_EXPIRED, 863 REUSE_EXPIRED,
864 REUSE_TRUNCATED, 864 REUSE_TRUNCATED,
865 REUSE_VARY, 865 REUSE_VARY,
866 REUSE_DUMMY_VALUE, 866 REUSE_DUMMY_VALUE,
867 // Not an individual value; it's added to another reason. 867 // Not an individual value; it's added to another reason.
868 REUSE_REVALIDATEABLE = 7 868 REUSE_REVALIDATEABLE = 7
869 }; 869 };
870 int reason = REUSE_OK; 870 int reason = REUSE_OK;
871 871
872 if (old.flags & NO_CACHE)
873 reason = REUSE_NO_CACHE;
874
875 if (old.flags & EXPIRED)
876 reason = REUSE_ALWAYS_EXPIRED;
877
878 if (old.flags & TRUNCATED)
879 reason = REUSE_TRUNCATED;
880
881 Time expiration = IntToTime(old.expiration); 872 Time expiration = IntToTime(old.expiration);
882 if (expiration < Time::Now()) 873 if (expiration < Time::Now())
883 reason = REUSE_EXPIRED; 874 reason = REUSE_EXPIRED;
884 875
876 if (old.flags & EXPIRED)
877 reason = REUSE_ALWAYS_EXPIRED;
878
879 if (old.flags & NO_CACHE)
880 reason = REUSE_NO_CACHE;
881
882 if (old.flags & TRUNCATED)
883 reason = REUSE_TRUNCATED;
884
885 if (old.vary_hash != current.vary_hash) 885 if (old.vary_hash != current.vary_hash)
886 reason = REUSE_VARY; 886 reason = REUSE_VARY;
887 887
888 bool have_to_drop = (old.flags & TRUNCATED) && !(old.flags & RESUMABLE); 888 bool have_to_drop = (old.flags & TRUNCATED) && !(old.flags & RESUMABLE);
889 if (reason && (old.flags & REVALIDATEABLE) && !have_to_drop) 889 if (reason && (old.flags & REVALIDATEABLE) && !have_to_drop)
890 reason += REUSE_REVALIDATEABLE; 890 reason += REUSE_REVALIDATEABLE;
891 891
892 UMA_HISTOGRAM_ENUMERATION("InfiniteCache.ReuseFailure", reason, 15); 892 UMA_HISTOGRAM_ENUMERATION("InfiniteCache.ReuseFailure", reason, 15);
893 return !reason; 893 return !reason;
894 } 894 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 int InfiniteCache::FlushDataForTest(const CompletionCallback& callback) { 1014 int InfiniteCache::FlushDataForTest(const CompletionCallback& callback) {
1015 DCHECK(worker_); 1015 DCHECK(worker_);
1016 int* result = new int; 1016 int* result = new int;
1017 task_runner_->PostTaskAndReply( 1017 task_runner_->PostTaskAndReply(
1018 FROM_HERE, base::Bind(&InfiniteCache::Worker::Flush, worker_, result), 1018 FROM_HERE, base::Bind(&InfiniteCache::Worker::Flush, worker_, result),
1019 base::Bind(&OnComplete, callback, base::Owned(result))); 1019 base::Bind(&OnComplete, callback, base::Owned(result)));
1020 return net::ERR_IO_PENDING; 1020 return net::ERR_IO_PENDING;
1021 } 1021 }
1022 1022
1023 } // namespace net 1023 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698