Skip to content

Commit eee26ef

Browse files
dtapuskaChromium LUCI CQ
authored andcommitted
Avoid using a WebContentsObserver where it is unnecessary.
The DataReductionProxyTabHelper doesn't need to be a WebContentsObserver to obtain the current associated WebContents because its lifecycle is tied to the WebContents object. It can just store the WebContents ptr directly in the object. BUG=952390 Change-Id: I7246e12212e45bcfe788447a0bf502c2154833c5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3145256 Reviewed-by: Robert Ogden <[email protected]> Commit-Queue: Dave Tapuska <[email protected]> Cr-Commit-Position: refs/heads/main@{#918851}
1 parent c1a970f commit eee26ef

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

chrome/browser/data_reduction_proxy/data_reduction_proxy_tab_helper.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
DataReductionProxyTabHelper::DataReductionProxyTabHelper(
1616
content::WebContents* web_contents)
17-
: content::WebContentsObserver(web_contents) {
17+
: web_contents_(web_contents) {
1818
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
1919

2020
drp_settings_ = DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
@@ -40,7 +40,7 @@ void DataReductionProxyTabHelper::OnDataSaverEnabledChanged(bool enabled) {
4040
}
4141

4242
void DataReductionProxyTabHelper::UpdateWebkitPreferencesNow() {
43-
web_contents()->OnWebPreferencesChanged();
43+
web_contents_->OnWebPreferencesChanged();
4444
}
4545

4646
WEB_CONTENTS_USER_DATA_KEY_IMPL(DataReductionProxyTabHelper)

chrome/browser/data_reduction_proxy/data_reduction_proxy_tab_helper.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
#include "base/macros.h"
99
#include "base/memory/weak_ptr.h"
1010
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h"
11-
#include "content/public/browser/web_contents_observer.h"
1211
#include "content/public/browser/web_contents_user_data.h"
1312

1413
// Tracks when the Data Saver setting is enabled or disabled and notifies
1514
// content.
1615
class DataReductionProxyTabHelper
17-
: public content::WebContentsObserver,
18-
public content::WebContentsUserData<DataReductionProxyTabHelper>,
16+
: public content::WebContentsUserData<DataReductionProxyTabHelper>,
1917
public data_reduction_proxy::DataReductionProxySettingsObserver {
2018
public:
2119
~DataReductionProxyTabHelper() override;
@@ -37,6 +35,8 @@ class DataReductionProxyTabHelper
3735

3836
data_reduction_proxy::DataReductionProxySettings* drp_settings_;
3937

38+
content::WebContents* const web_contents_;
39+
4040
base::WeakPtrFactory<DataReductionProxyTabHelper> weak_factory_{this};
4141

4242
WEB_CONTENTS_USER_DATA_KEY_DECL();

0 commit comments

Comments
 (0)