-
Notifications
You must be signed in to change notification settings - Fork 883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable network time tracker #792
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#include "components/network_time/network_time_tracker.h" | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <utility> | ||
|
||
#include "base/compiler_specific.h" | ||
#include "base/message_loop/message_loop.h" | ||
#include "base/run_loop.h" | ||
#include "base/strings/stringprintf.h" | ||
#include "base/test/bind_test_util.h" | ||
#include "base/test/scoped_task_environment.h" | ||
#include "base/test/simple_test_clock.h" | ||
#include "base/test/simple_test_tick_clock.h" | ||
#include "components/client_update_protocol/ecdsa.h" | ||
#include "components/network_time/network_time_pref_names.h" | ||
#include "components/network_time/network_time_test_utils.h" | ||
#include "components/prefs/testing_pref_service.h" | ||
#include "net/http/http_response_headers.h" | ||
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h" | ||
#include "services/network/test/test_url_loader_factory.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace network_time { | ||
|
||
class NetworkTimeTrackerTest : public ::testing::Test { | ||
public: | ||
~NetworkTimeTrackerTest() override {} | ||
|
||
NetworkTimeTrackerTest() | ||
: task_environment_( | ||
base::test::ScopedTaskEnvironment::MainThreadType::IO), | ||
clock_(new base::SimpleTestClock), | ||
tick_clock_(new base::SimpleTestTickClock), | ||
test_shared_loader_factory_( | ||
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>( | ||
&test_url_loader_factory_)) { | ||
NetworkTimeTracker::RegisterPrefs(pref_service_.registry()); | ||
tracker_.reset(new NetworkTimeTracker( | ||
std::unique_ptr<base::Clock>(clock_), | ||
std::unique_ptr<const base::TickClock>(tick_clock_), &pref_service_, | ||
shared_url_loader_factory())); | ||
} | ||
|
||
protected: | ||
scoped_refptr<network::SharedURLLoaderFactory> shared_url_loader_factory() { | ||
return test_shared_loader_factory_; | ||
} | ||
network::TestURLLoaderFactory* test_url_loader_factory() { | ||
return &test_url_loader_factory_; | ||
} | ||
|
||
base::test::ScopedTaskEnvironment task_environment_; | ||
base::SimpleTestClock* clock_; | ||
base::SimpleTestTickClock* tick_clock_; | ||
TestingPrefServiceSimple pref_service_; | ||
std::unique_ptr<NetworkTimeTracker> tracker_; | ||
network::TestURLLoaderFactory test_url_loader_factory_; | ||
scoped_refptr<network::SharedURLLoaderFactory> test_shared_loader_factory_; | ||
}; | ||
|
||
TEST_F(NetworkTimeTrackerTest, Disabled) { | ||
EXPECT_FALSE(tracker_->AreTimeFetchesEnabled()); | ||
} | ||
|
||
TEST_F(NetworkTimeTrackerTest, NoFetch) { | ||
bool network_access_occurred = false; | ||
test_url_loader_factory()->SetInterceptor( | ||
base::BindLambdaForTesting([&](const network::ResourceRequest& request) { | ||
network_access_occurred = true; | ||
})); | ||
tracker_->QueryTimeServiceForTesting(); | ||
EXPECT_FALSE(network_access_occurred); | ||
} | ||
|
||
} // namespace network_time |
13 changes: 13 additions & 0 deletions
13
patches/components-network_time-network_time_tracker.cc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/components/network_time/network_time_tracker.cc b/components/network_time/network_time_tracker.cc | ||
index 34386ad169f8..ab8efddc9794 100644 | ||
--- a/components/network_time/network_time_tracker.cc | ||
+++ b/components/network_time/network_time_tracker.cc | ||
@@ -277,7 +277,7 @@ void NetworkTimeTracker::UpdateNetworkTime(base::Time network_time, | ||
} | ||
|
||
bool NetworkTimeTracker::AreTimeFetchesEnabled() const { | ||
- return base::FeatureList::IsEnabled(kNetworkTimeServiceQuerying); | ||
+ return false; // feature disabled in Brave | ||
} | ||
|
||
NetworkTimeTracker::FetchBehavior NetworkTimeTracker::GetFetchBehavior() const { |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretty sure we could remove this patch by disabling the feature instead