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

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc

Issue 2581313002: Cleanup DataReductionProxy (DRP) Brotli code (Closed)
Patch Set: Fix thread checker Created 4 years 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
Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc
index d4f6ae26af03f4a97316ffbc0b7e5f5bbc136cb6..3b66f062cfac060f17d34b117628927289716f63 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc
@@ -77,17 +77,23 @@ DataReductionProxyRequestOptions::DataReductionProxyRequestOptions(
data_reduction_proxy_config_(config) {
DCHECK(data_reduction_proxy_config_);
util::GetChromiumBuildAndPatch(version, &build_, &patch_);
- // Constructed on the UI thread, but should be checked on the IO thread.
- thread_checker_.DetachFromThread();
}
DataReductionProxyRequestOptions::~DataReductionProxyRequestOptions() {
}
void DataReductionProxyRequestOptions::Init() {
+ DCHECK(thread_checker_.CalledOnValidThread());
key_ = GetDefaultKey(),
UpdateCredentials();
UpdateExperiments();
+ // Called on the UI thread, but should be checked on the IO thread.
+ thread_checker_.DetachFromThread();
+}
+
+std::string DataReductionProxyRequestOptions::GetHeaderValueForTesting() const {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ return header_value_;
}
void DataReductionProxyRequestOptions::UpdateExperiments() {
@@ -133,16 +139,19 @@ base::string16 DataReductionProxyRequestOptions::AuthHashForSalt(
}
base::Time DataReductionProxyRequestOptions::Now() const {
+ DCHECK(thread_checker_.CalledOnValidThread());
return base::Time::Now();
}
void DataReductionProxyRequestOptions::RandBytes(void* output,
size_t length) const {
+ DCHECK(thread_checker_.CalledOnValidThread());
crypto::RandBytes(output, length);
}
void DataReductionProxyRequestOptions::AddRequestHeader(
net::HttpRequestHeaders* request_headers) {
+ DCHECK(thread_checker_.CalledOnValidThread());
base::Time now = Now();
// Authorization credentials must be regenerated if they are expired.
if (!use_assigned_credentials_ && (now > credentials_expiration_time_))
@@ -207,10 +216,12 @@ void DataReductionProxyRequestOptions::SetSecureSession(
}
void DataReductionProxyRequestOptions::Invalidate() {
+ DCHECK(thread_checker_.CalledOnValidThread());
SetSecureSession(std::string());
}
std::string DataReductionProxyRequestOptions::GetDefaultKey() const {
+ DCHECK(thread_checker_.CalledOnValidThread());
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
std::string key =

Powered by Google App Engine
This is Rietveld 408576698