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

Unified Diff: chrome/browser/data_use_measurement/chrome_data_use_ascriber.h

Issue 2413663003: Expose GlobalRequestID in NavigationHandle and ResourceRequestInfo. (Closed)
Patch Set: Use OnURLRequestDestroyed Created 4 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 | « no previous file | chrome/browser/data_use_measurement/chrome_data_use_ascriber.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/data_use_measurement/chrome_data_use_ascriber.h
diff --git a/chrome/browser/data_use_measurement/chrome_data_use_ascriber.h b/chrome/browser/data_use_measurement/chrome_data_use_ascriber.h
index 4b8c3171c32c75f725374ef4c3ea1278d223934f..74bc6db9aba73d6be112ef759ec66cd5ca603f50 100644
--- a/chrome/browser/data_use_measurement/chrome_data_use_ascriber.h
+++ b/chrome/browser/data_use_measurement/chrome_data_use_ascriber.h
@@ -5,8 +5,17 @@
#ifndef CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_H_
#define CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_H_
+#include <list>
+#include <memory>
+#include <unordered_map>
+#include <utility>
+
+#include "base/containers/hash_tables.h"
+#include "base/hash.h"
#include "base/macros.h"
+#include "base/supports_user_data.h"
#include "components/data_use_measurement/core/data_use_ascriber.h"
+#include "content/public/browser/global_request_id.h"
#include "url/gurl.h"
namespace content {
@@ -41,9 +50,15 @@ class ChromeDataUseAscriber : public DataUseAscriber {
~ChromeDataUseAscriber() override;
- // DataUseAscriber:
+ // DataUseAscriber implementation:
DataUseRecorder* GetDataUseRecorder(net::URLRequest* request) override;
+ // Called before a request is sent.
+ void OnBeforeUrlRequest(net::URLRequest* request) override;
+
+ // Called when a URLRequest is being destroyed.
+ void OnUrlRequestDestroyed(net::URLRequest* request) override;
+
// Called when a render frame host is created.
void RenderFrameCreated(int render_process_id,
int render_frame_id,
@@ -62,12 +77,15 @@ class ChromeDataUseAscriber : public DataUseAscriber {
int render_frame_id,
void* navigation_handle);
- // Called when a main frame navigation is completed.
- void DidFinishMainFrameNavigation(GURL gurl,
- int render_process_id,
- int render_frame_id,
- bool is_same_page_navigation,
- void* navigation_handle);
+ // Called when a main frame navigation is ready to be committed in a
+ // renderer.
+ void ReadyToCommitMainFrameNavigation(
+ GURL gurl,
+ content::GlobalRequestID global_request_id,
+ int render_process_id,
+ int render_frame_id,
+ bool is_same_page_navigation,
+ void* navigation_handle);
// Called when a main frame navigation is redirected.
void DidRedirectMainFrameNavigation(GURL gurl,
@@ -76,6 +94,56 @@ class ChromeDataUseAscriber : public DataUseAscriber {
void* navigation_handle);
private:
+ // Use as a key in the render frame map. Corresponds to a unique
+ // RenderFrameHost.
+ typedef std::pair<int, int> RenderFrameHostID;
+
+ // Entry in the |data_use_recorders_| list which owns all instances of
+ // DataUseRecorder.
+ typedef std::list<std::unique_ptr<data_use_measurement::DataUseRecorder>>::
+ iterator DataUseRecorderEntry;
+
+ struct GlobalRequestIDHash {
+ public:
+ std::size_t operator()(const content::GlobalRequestID& x) const {
+ return base::HashInts(x.child_id, x.request_id);
+ }
+ };
+
+ class DataUseRecorderEntryAsUserData : public base::SupportsUserData::Data {
+ public:
+ explicit DataUseRecorderEntryAsUserData(DataUseRecorderEntry entry);
+
+ ~DataUseRecorderEntryAsUserData() override;
+
+ DataUseRecorderEntry recorder_entry() { return entry_; }
+
+ static const void* kUserDataKey;
+
+ private:
+ DataUseRecorderEntry entry_;
+ };
+
+ void DeletePendingNavigationEntry(content::GlobalRequestID global_request_id);
+
+ // Owner for all instances of DataUseRecorder. An instance is kept in this
+ // list if any entity (render frame hosts, URLRequests, pending navigations)
+ // that ascribe data use to the instance exists, and deleted when all
+ // ascribing entities go away.
+ std::list<std::unique_ptr<DataUseRecorder>> data_use_recorders_;
+
+ // Map from RenderFrameHost to the DataUseRecorderEntry in
+ // |data_use_recorders_| that the frame ascribe data use to.
+ base::hash_map<RenderFrameHostID, DataUseRecorderEntry>
+ render_frame_data_use_map_;
+
+ // Map from pending navigations to the DataUseRecorderEntry in
+ // |data_use_recorders_| that the navigation ascribes data use to.
+ std::unordered_map<content::GlobalRequestID,
+ DataUseRecorderEntry,
+ GlobalRequestIDHash>
+ pending_navigation_data_use_map_;
+
DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriber);
};
« no previous file with comments | « no previous file | chrome/browser/data_use_measurement/chrome_data_use_ascriber.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698