Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_H_ | 5 #ifndef CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_H_ |
| 6 #define CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_H_ | 6 #define CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_H_ |
| 7 | 7 |
| 8 #include <list> | |
| 9 #include <memory> | |
| 10 #include <utility> | |
| 11 | |
| 12 #include "base/containers/hash_tables.h" | |
| 13 #include "base/hash.h" | |
| 8 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/supports_user_data.h" | |
| 9 #include "components/data_use_measurement/core/data_use_ascriber.h" | 16 #include "components/data_use_measurement/core/data_use_ascriber.h" |
| 17 #include "content/public/browser/global_request_id.h" | |
| 10 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 11 | 19 |
| 12 namespace content { | 20 namespace content { |
| 13 class NavigationHandle; | 21 class NavigationHandle; |
| 14 class RenderFrameHost; | 22 class RenderFrameHost; |
| 15 } | 23 } |
| 16 | 24 |
| 17 namespace data_use_measurement { | 25 namespace data_use_measurement { |
| 18 | 26 |
| 19 // Browser implementation of DataUseAscriber. Maintains a list of | 27 // Browser implementation of DataUseAscriber. Maintains a list of |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 37 // navigation information on the IO thread. | 45 // navigation information on the IO thread. |
| 38 class ChromeDataUseAscriber : public DataUseAscriber { | 46 class ChromeDataUseAscriber : public DataUseAscriber { |
| 39 public: | 47 public: |
| 40 ChromeDataUseAscriber(); | 48 ChromeDataUseAscriber(); |
| 41 | 49 |
| 42 ~ChromeDataUseAscriber() override; | 50 ~ChromeDataUseAscriber() override; |
| 43 | 51 |
| 44 // DataUseAscriber: | 52 // DataUseAscriber: |
| 45 DataUseRecorder* GetDataUseRecorder(net::URLRequest* request) override; | 53 DataUseRecorder* GetDataUseRecorder(net::URLRequest* request) override; |
| 46 | 54 |
| 55 void OnBeforeUrlRequest(net::URLRequest* request) override; | |
| 56 | |
| 47 // Called when a render frame host is created. | 57 // Called when a render frame host is created. |
| 48 void RenderFrameCreated(int render_process_id, | 58 void RenderFrameCreated(int render_process_id, |
| 49 int render_frame_id, | 59 int render_frame_id, |
| 50 int parent_render_process_id, | 60 int parent_render_process_id, |
| 51 int parent_render_frame_id); | 61 int parent_render_frame_id); |
| 52 | 62 |
| 53 // Called when a render frame host is deleted. | 63 // Called when a render frame host is deleted. |
| 54 void RenderFrameDeleted(int render_process_id, | 64 void RenderFrameDeleted(int render_process_id, |
| 55 int render_frame_id, | 65 int render_frame_id, |
| 56 int parent_render_process_id, | 66 int parent_render_process_id, |
| 57 int parent_render_frame_id); | 67 int parent_render_frame_id); |
| 58 | 68 |
| 59 // Called when a main frame navigation is started. | 69 // Called when a main frame navigation is started. |
| 60 void DidStartMainFrameNavigation(GURL gurl, | 70 void DidStartMainFrameNavigation(GURL gurl, |
| 61 int render_process_id, | 71 int render_process_id, |
| 62 int render_frame_id, | 72 int render_frame_id, |
| 63 void* navigation_handle); | 73 void* navigation_handle); |
| 64 | 74 |
| 65 // Called when a main frame navigation is completed. | 75 // Called when a main frame navigation is completed. |
| 66 void DidFinishMainFrameNavigation(GURL gurl, | 76 void DidFinishMainFrameNavigation(GURL gurl, |
| 77 content::GlobalRequestID global_request_id, | |
| 67 int render_process_id, | 78 int render_process_id, |
| 68 int render_frame_id, | 79 int render_frame_id, |
| 69 bool is_same_page_navigation, | 80 bool is_same_page_navigation, |
| 70 void* navigation_handle); | 81 void* navigation_handle); |
| 71 | 82 |
| 72 // Called when a main frame navigation is redirected. | 83 // Called when a main frame navigation is redirected. |
| 73 void DidRedirectMainFrameNavigation(GURL gurl, | 84 void DidRedirectMainFrameNavigation(GURL gurl, |
| 74 int render_process_id, | 85 int render_process_id, |
| 75 int render_frame_id, | 86 int render_frame_id, |
| 76 void* navigation_handle); | 87 void* navigation_handle); |
| 77 | 88 |
| 89 void OnUrlRequestCompleted(net::URLRequest* request, bool started) override; | |
| 90 | |
| 78 private: | 91 private: |
| 92 typedef std::pair<int, int> RenderFrameHostID; | |
| 93 typedef std::list<std::unique_ptr<data_use_measurement::DataUseRecorder>>:: | |
|
Raj
2016/10/27 20:33:56
I wonder whether following typedefs could be easie
RyanSturm
2016/10/27 22:41:21
+1
maybe add a typedef for std::unique_ptr<data_u
Not at Google. Contact bengr
2016/10/28 18:43:33
std::list<std::unique_ptr<DataUseRecorder>> is onl
| |
| 94 iterator DataUseRecorderEntry; | |
| 95 | |
| 96 class DataUseRecorderEntryAsUserData : public base::SupportsUserData::Data { | |
|
RyanSturm
2016/10/27 22:41:21
I think you can anonymous namespace this class sin
Not at Google. Contact bengr
2016/10/28 18:43:33
This class uses DataUseRecorderEntry which is a pr
| |
| 97 public: | |
| 98 explicit DataUseRecorderEntryAsUserData(DataUseRecorderEntry entry); | |
| 99 | |
| 100 ~DataUseRecorderEntryAsUserData() override; | |
| 101 | |
| 102 DataUseRecorderEntry recorder_entry() { return entry_; } | |
| 103 | |
| 104 static const void* kUserDataKey; | |
| 105 | |
| 106 private: | |
| 107 DataUseRecorderEntry entry_; | |
| 108 }; | |
| 109 | |
| 110 struct GlobalRequestIDHash { | |
|
Raj
2016/10/27 20:33:56
nit: Could this be in anonymous namespace in this
Not at Google. Contact bengr
2016/10/28 18:43:33
Yes, but doesn't get us anything. Any file includi
RyanSturm
2016/11/02 21:41:58
This has to be used in this file, and anonymous na
| |
| 111 public: | |
| 112 std::size_t operator()(const content::GlobalRequestID& x) const { | |
| 113 return base::HashInts(x.child_id, x.request_id); | |
| 114 } | |
| 115 }; | |
| 116 | |
| 117 std::list<std::unique_ptr<DataUseRecorder>> data_use_recorders_; | |
|
Raj
2016/10/27 20:33:56
If using DataUseRecorderList, change std::list<std
Not at Google. Contact bengr
2016/10/28 18:43:33
See above.
| |
| 118 | |
| 119 base::hash_map<RenderFrameHostID, DataUseRecorderEntry> | |
| 120 render_frame_data_use_map_; | |
| 121 | |
| 122 base::hash_map<content::GlobalRequestID, | |
|
RyanSturm
2016/10/27 22:41:21
nit: Can this be?
std::unordered_map<RenderFrameHo
Not at Google. Contact bengr
2016/10/28 18:43:33
Done.
| |
| 123 DataUseRecorderEntry, | |
| 124 GlobalRequestIDHash> | |
| 125 pending_navigation_data_use_map_; | |
| 126 | |
| 79 DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriber); | 127 DISALLOW_COPY_AND_ASSIGN(ChromeDataUseAscriber); |
| 80 }; | 128 }; |
| 81 | 129 |
| 82 } // namespace data_use_measurement | 130 } // namespace data_use_measurement |
| 83 | 131 |
| 84 #endif // CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_H_ | 132 #endif // CHROME_BROWSER_DATA_USE_MEASUREMENT_CHROME_DATA_USE_ASCRIBER_H_ |
| OLD | NEW |