summaryrefslogtreecommitdiffstats
path: root/net/url_request/request_tracker.h
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-21 20:03:19 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-21 20:03:19 +0000
commitc1173dd1715877a08f641c4f94ff709de51ada58 (patch)
tree3a9eb057baa02f54dd863788562bbb6ea765bc45 /net/url_request/request_tracker.h
parent4460d9ceda27029cd1474141ec9f114a5b4eadef (diff)
downloadchromium_src-c1173dd1715877a08f641c4f94ff709de51ada58.zip
chromium_src-c1173dd1715877a08f641c4f94ff709de51ada58.tar.gz
chromium_src-c1173dd1715877a08f641c4f94ff709de51ada58.tar.bz2
Add the ability to enable full logging for LoadLogs.
This works by clicking a button in about:net-internals to turn on active logging. Right now full logging means: - Instead of just the most recent 25 requests, keep all requests info. - Instead of limiting each request to 50 log entries, keep all log entries. - Instead of saving the first 1000 bytes of request URLs, save all its bytes. In the future full logging will be expanded to include other log events, and also string messages (so it can mirror what was sent to LOG(INFO) / LOG(WARNING)). BUG=27552 Review URL: http://codereview.chromium.org/507055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35098 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/url_request/request_tracker.h')
-rw-r--r--net/url_request/request_tracker.h62
1 files changed, 55 insertions, 7 deletions
diff --git a/net/url_request/request_tracker.h b/net/url_request/request_tracker.h
index abfdf4b..3202e60 100644
--- a/net/url_request/request_tracker.h
+++ b/net/url_request/request_tracker.h
@@ -40,13 +40,22 @@ class RequestTracker {
typedef std::vector<RecentRequestInfo> RecentRequestInfoList;
typedef bool (*RecentRequestsFilterFunc)(const GURL&);
- // The maximum number of entries for |graveyard_|.
+ // The maximum number of entries for |graveyard_|, when in bounded mode.
static const size_t kMaxGraveyardSize;
- // The maximum size of URLs to stuff into RecentRequestInfo.
+ // The maximum size of URLs to stuff into RecentRequestInfo, when in bounded
+ // mode.
static const size_t kMaxGraveyardURLSize;
- RequestTracker() : next_graveyard_index_(0), graveyard_filter_func_(NULL) {}
+ // The maximum number of entries to use for LoadLogs when in bounded mode.
+ static const size_t kBoundedLoadLogMaxEntries;
+
+ RequestTracker()
+ : next_graveyard_index_(0),
+ graveyard_filter_func_(NULL),
+ is_unbounded_(false) {
+ }
+
~RequestTracker() {}
// Returns a list of Requests that are alive.
@@ -90,10 +99,13 @@ class RequestTracker {
RecentRequestInfo info;
request->GetInfoForTracker(&info);
- // Paranoia check: truncate |info.original_url| if it is really big.
- const std::string& spec = info.original_url.possibly_invalid_spec();
- if (spec.size() > kMaxGraveyardURLSize)
- info.original_url = GURL(spec.substr(0, kMaxGraveyardURLSize));
+
+ if (!is_unbounded_) {
+ // Paranoia check: truncate |info.original_url| if it is really big.
+ const std::string& spec = info.original_url.possibly_invalid_spec();
+ if (spec.size() > kMaxGraveyardURLSize)
+ info.original_url = GURL(spec.substr(0, kMaxGraveyardURLSize));
+ }
if (ShouldInsertIntoGraveyard(info)) {
// Add into |graveyard_|.
@@ -109,6 +121,31 @@ class RequestTracker {
graveyard_filter_func_ = filter_func;
}
+ bool IsUnbounded() const {
+ return is_unbounded_;
+ }
+
+ void SetUnbounded(bool unbounded) {
+ // No change.
+ if (is_unbounded_ == unbounded)
+ return;
+
+ // If we are going from unbounded to bounded, we need to trim the
+ // graveyard. For simplicity we will simply clear it.
+ if (is_unbounded_ && !unbounded)
+ ClearRecentlyDeceased();
+
+ is_unbounded_ = unbounded;
+ }
+
+ // Creates a LoadLog using the unbounded/bounded constraints that
+ // apply to this tracker.
+ net::LoadLog* CreateLoadLog() {
+ if (IsUnbounded())
+ return new net::LoadLog(net::LoadLog::kUnbounded);
+ return new net::LoadLog(kBoundedLoadLogMaxEntries);
+ }
+
private:
bool ShouldInsertIntoGraveyard(const RecentRequestInfo& info) {
if (!graveyard_filter_func_)
@@ -117,6 +154,13 @@ class RequestTracker {
}
void InsertIntoGraveyard(const RecentRequestInfo& info) {
+ if (is_unbounded_) {
+ graveyard_.push_back(info);
+ return;
+ }
+
+ // Otherwise enforce a bound on the graveyard size, by treating it as a
+ // circular buffer.
if (graveyard_.size() < kMaxGraveyardSize) {
// Still growing to maximum capacity.
DCHECK_EQ(next_graveyard_index_, graveyard_.size());
@@ -133,6 +177,7 @@ class RequestTracker {
size_t next_graveyard_index_;
RecentRequestInfoList graveyard_;
RecentRequestsFilterFunc graveyard_filter_func_;
+ bool is_unbounded_;
};
template<typename Request>
@@ -141,4 +186,7 @@ const size_t RequestTracker<Request>::kMaxGraveyardSize = 25;
template<typename Request>
const size_t RequestTracker<Request>::kMaxGraveyardURLSize = 1000;
+template<typename Request>
+const size_t RequestTracker<Request>::kBoundedLoadLogMaxEntries = 50;
+
#endif // NET_URL_REQUEST_REQUEST_TRACKER_H_