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

Unified Diff: net/http/infinite_cache.cc

Issue 10986034: Track ga.js through the cache. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chrome_browser_field_trials.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/infinite_cache.cc
diff --git a/net/http/infinite_cache.cc b/net/http/infinite_cache.cc
index c6b0829a15845bbf50954ad53492320a01069d5d..af18f5b39bbe6998f808b0d3dbb41217304a9ab0 100644
--- a/net/http/infinite_cache.cc
+++ b/net/http/infinite_cache.cc
@@ -45,7 +45,9 @@ enum Flags {
RESUMABLE = 1 << 4,
REVALIDATEABLE = 1 << 5,
DOOM_METHOD = 1 << 6,
- CACHED = 1 << 7
+ CACHED = 1 << 7,
+ GA_JS = 1 << 8,
+ GA_JS_HTTPS = 1 << 9, // 0 means HTTP, 1 means HTTPS
};
const int kKeySizeBytes = 20;
@@ -226,6 +228,9 @@ struct hash<Key> {
namespace net {
+static const char kGaJsHttpUrl[] = "http://www.google-analytics.com/ga.js";
+static const char kGaJsHttpsUrl[] = "https://ssl.google-analytics.com/ga.js";
+
struct InfiniteCacheTransaction::ResourceData {
ResourceData() {
memset(this, 0, sizeof(*this));
@@ -247,15 +252,23 @@ void InfiniteCacheTransaction::OnRequestStart(const HttpRequestInfo* request) {
if (!cache_)
return;
+ scoped_ptr<ResourceData> resource_data(new ResourceData);
std::string method = request->method;
if (method == "POST" || method == "DELETE" || method == "PUT") {
must_doom_entry_ = true;
} else if (method != "GET") {
cache_.reset();
return;
+ } else {
+ const std::string cache_key = HttpUtil::SpecForRequest(request->url);
+ if (cache_key == kGaJsHttpUrl) {
+ resource_data_->details.flags &= GA_JS;
+ } else if (cache_key == kGaJsHttpsUrl) {
+ resource_data_->details.flags &= GA_JS | GA_JS_HTTPS;
+ }
}
- resource_data_.reset(new ResourceData);
rvargas (doing something else) 2012/09/28 21:51:15 move this line up to line 250 (in this version).
willchan no longer on Chromium 2012/09/28 22:07:55 I'm fine with that, but in the method != "GET" cas
+ resource_data_.swap(resource_data);
CryptoHash(cache_->GenerateKey(request), &resource_data_->key);
}
@@ -266,6 +279,10 @@ void InfiniteCacheTransaction::OnResponseReceived(
Details& details = resource_data_->details;
+ // Store the old ga.js flag values.
+ const uint32 kGaJsBitMask = (GA_JS|GA_JS_HTTPS);
+ uint32 old_ga_js_values = details.flags & kGaJsBitMask;
+
details.expiration = GetExpiration(response);
details.last_access = TimeToInt(response->request_time);
details.flags = GetCacheability(response);
@@ -276,6 +293,10 @@ void InfiniteCacheTransaction::OnResponseReceived(
TimeToInt(response->response_time) == details.expiration) {
details.flags = EXPIRED;
}
+
+ // Restore the old ga.js flag values.
+ details.flags |= old_ga_js_values;
rvargas (doing something else) 2012/09/28 21:51:15 I knew there was a reason for passing DOOM_METHOD
willchan no longer on Chromium 2012/09/28 22:07:55 I don't get it...why?
+
details.flags |= GetRevalidationFlags(response);
if (must_doom_entry_)
@@ -772,25 +793,70 @@ void InfiniteCache::Worker::RecordHit(const Details& old, Details* details) {
header_->num_hits++;
int access_delta = (IntToTime(details->last_access) -
IntToTime(old.last_access)).InMinutes();
- if (old.use_count)
+ if (old.use_count) {
UMA_HISTOGRAM_COUNTS("InfiniteCache.ReuseAge", access_delta);
- else
+ if (details->flags & GA_JS) {
+ if (details->flags & GA_JS_HTTPS) {
+ UMA_HISTOGRAM_COUNTS("InfiniteCache.GaJsHttpsReuseAge", access_delta);
+ } else {
+ UMA_HISTOGRAM_COUNTS("InfiniteCache.GaJsHttpReuseAge", access_delta);
+ }
+ }
+ } else {
UMA_HISTOGRAM_COUNTS("InfiniteCache.FirstReuseAge", access_delta);
+ if (details->flags & GA_JS) {
+ if (details->flags & GA_JS_HTTPS) {
+ UMA_HISTOGRAM_COUNTS(
+ "InfiniteCache.GaJsHttpsFirstReuseAge", access_delta);
+ } else {
+ UMA_HISTOGRAM_COUNTS(
+ "InfiniteCache.GaJsHttpFirstReuseAge", access_delta);
+ }
+ }
+ }
details->use_count = old.use_count;
if (details->use_count < kuint8max)
details->use_count++;
UMA_HISTOGRAM_CUSTOM_COUNTS("InfiniteCache.UseCount", details->use_count, 0,
kuint8max, 25);
+ if (details->flags & GA_JS) {
+ if (details->flags & GA_JS_HTTPS) {
+ UMA_HISTOGRAM_CUSTOM_COUNTS("InfiniteCache.GaJsHttpsUseCount",
+ details->use_count, 0, kuint8max, 25);
+ } else {
+ UMA_HISTOGRAM_CUSTOM_COUNTS("InfiniteCache.GaJsHttpUseCount",
+ details->use_count, 0, kuint8max, 25);
+ }
+ }
}
void InfiniteCache::Worker::RecordUpdate(const Details& old, Details* details) {
int access_delta = (IntToTime(details->last_access) -
IntToTime(old.last_access)).InMinutes();
- if (old.update_count)
+ if (old.update_count) {
UMA_HISTOGRAM_COUNTS("InfiniteCache.UpdateAge", access_delta);
- else
+ if (details->flags & GA_JS) {
+ if (details->flags & GA_JS_HTTPS) {
+ UMA_HISTOGRAM_COUNTS(
+ "InfiniteCache.GaJsHttpsUpdateAge", access_delta);
+ } else {
+ UMA_HISTOGRAM_COUNTS(
+ "InfiniteCache.GaJsHttpUpdateAge", access_delta);
+ }
+ }
+ } else {
UMA_HISTOGRAM_COUNTS("InfiniteCache.FirstUpdateAge", access_delta);
+ if (details->flags & GA_JS) {
+ if (details->flags & GA_JS_HTTPS) {
+ UMA_HISTOGRAM_COUNTS(
+ "InfiniteCache.GaJsHttpsFirstUpdateAge", access_delta);
+ } else {
+ UMA_HISTOGRAM_COUNTS(
+ "InfiniteCache.GaJsHttpFirstUpdateAge", access_delta);
+ }
+ }
+ }
details->update_count = old.update_count;
if (details->update_count < kuint8max)
@@ -798,6 +864,15 @@ void InfiniteCache::Worker::RecordUpdate(const Details& old, Details* details) {
UMA_HISTOGRAM_CUSTOM_COUNTS("InfiniteCache.UpdateCount",
details->update_count, 0, kuint8max, 25);
+ if (details->flags & GA_JS) {
+ if (details->flags & GA_JS_HTTPS) {
+ UMA_HISTOGRAM_CUSTOM_COUNTS("InfiniteCache.GaJsHttpsUpdateCount",
+ details->update_count, 0, kuint8max, 25);
+ } else {
+ UMA_HISTOGRAM_CUSTOM_COUNTS("InfiniteCache.GaJsHttpUpdateCount",
+ details->update_count, 0, kuint8max, 25);
+ }
+ }
details->use_count = 0;
}
@@ -890,6 +965,15 @@ bool InfiniteCache::Worker::CanReuse(const Details& old,
reason += REUSE_REVALIDATEABLE;
UMA_HISTOGRAM_ENUMERATION("InfiniteCache.ReuseFailure", reason, 15);
+ if (current.flags & GA_JS) {
+ if (current.flags & GA_JS_HTTPS) {
+ UMA_HISTOGRAM_ENUMERATION(
+ "InfiniteCache.GaJsHttpsReuseFailure", reason, 15);
+ } else {
+ UMA_HISTOGRAM_ENUMERATION(
+ "InfiniteCache.GaJsHttpReuseFailure", reason, 15);
+ }
+ }
return !reason;
}
« no previous file with comments | « chrome/browser/chrome_browser_field_trials.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698