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

Unified Diff: components/domain_reliability/context.h

Issue 1180223006: Domain Reliability: Simplify configs and reports (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix memory leak in unittests Created 5 years, 1 month 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 | « components/domain_reliability/config_unittest.cc ('k') | components/domain_reliability/context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/domain_reliability/context.h
diff --git a/components/domain_reliability/context.h b/components/domain_reliability/context.h
index 528c8ab168721174099e89acf9c9b4acaac63621..86cdf939fe09ea9a4a7dd0de3cc9e1247a67c135 100644
--- a/components/domain_reliability/context.h
+++ b/components/domain_reliability/context.h
@@ -30,7 +30,7 @@ class DomainReliabilityUploader;
class MockableTime;
// The per-domain context for the Domain Reliability client; includes the
-// domain's config and per-resource beacon queues.
+// domain's config and beacon queue.
class DOMAIN_RELIABILITY_EXPORT DomainReliabilityContext {
public:
class DOMAIN_RELIABILITY_EXPORT Factory {
@@ -53,7 +53,7 @@ class DOMAIN_RELIABILITY_EXPORT DomainReliabilityContext {
// Notifies the context of a beacon on its domain(s); may or may not save the
// actual beacon to be uploaded, depending on the sample rates in the config,
// but will increment one of the request counters in any case.
- void OnBeacon(const GURL& url, const DomainReliabilityBeacon& beacon);
+ void OnBeacon(scoped_ptr<DomainReliabilityBeacon> beacon);
// Called to clear browsing data, since beacons are like browsing history.
void ClearBeacons();
@@ -62,13 +62,11 @@ class DOMAIN_RELIABILITY_EXPORT DomainReliabilityContext {
// debugging purposes.
scoped_ptr<base::Value> GetWebUIData() const;
+ // Gets the beacons queued for upload in this context. |*beacons_out| will be
+ // cleared and filled with pointers to the beacons; the pointers remain valid
+ // as long as no other requests are reported to the DomainReliabilityMonitor.
void GetQueuedBeaconsForTesting(
- std::vector<DomainReliabilityBeacon>* beacons_out) const;
-
- void GetRequestCountsForTesting(
- size_t resource_index,
- uint32* successful_requests_out,
- uint32* failed_requests_out) const;
+ std::vector<const DomainReliabilityBeacon*>* beacons_out) const;
const DomainReliabilityConfig& config() const { return *config_.get(); }
@@ -77,18 +75,15 @@ class DOMAIN_RELIABILITY_EXPORT DomainReliabilityContext {
static const size_t kMaxQueuedBeacons;
private:
- class ResourceState;
-
- typedef std::deque<DomainReliabilityBeacon> BeaconDeque;
- typedef ScopedVector<ResourceState> ResourceStateVector;
- typedef ResourceStateVector::const_iterator ResourceStateIterator;
+ // Deque of beacons owned by this context. (Deleted after uploading.)
+ typedef std::deque<DomainReliabilityBeacon*> BeaconDeque;
- void InitializeResourceStates();
void ScheduleUpload(base::TimeDelta min_delay, base::TimeDelta max_delay);
void StartUpload();
void OnUploadComplete(const DomainReliabilityUploader::UploadResult& result);
- scoped_ptr<const base::Value> CreateReport(base::TimeTicks upload_time) const;
+ scoped_ptr<const base::Value> CreateReport(base::TimeTicks upload_time,
+ const GURL& collector_url) const;
// Remembers the current state of the context when an upload starts. Can be
// called multiple times in a row (without |CommitUpload|) if uploads fail
@@ -114,9 +109,6 @@ class DOMAIN_RELIABILITY_EXPORT DomainReliabilityContext {
BeaconDeque beacons_;
size_t uploading_beacons_size_;
- // Each ResourceState in |states_| corresponds to the Resource of the same
- // index in the config.
- ResourceStateVector states_;
base::TimeTicks upload_time_;
base::TimeTicks last_upload_time_;
// The last network change time is not tracked per-context, so this is a
« no previous file with comments | « components/domain_reliability/config_unittest.cc ('k') | components/domain_reliability/context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698