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

Unified Diff: components/safe_browsing_db/v4_update_protocol_manager.cc

Issue 2062013002: Fetch incremental updates. Store new state in V4Store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits: Added some comments in BUILD.gn. Using #else for platform_type until I resolve the android bu… Created 4 years, 6 months 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/safe_browsing_db/v4_update_protocol_manager.cc
diff --git a/components/safe_browsing_db/v4_update_protocol_manager.cc b/components/safe_browsing_db/v4_update_protocol_manager.cc
index f0fad8d07acf607a566378cdc9baf9f0eaf42e7c..49781452a8f4381e67ee5ecfd30adb86a9531f3a 100644
--- a/components/safe_browsing_db/v4_update_protocol_manager.cc
+++ b/components/safe_browsing_db/v4_update_protocol_manager.cc
@@ -77,11 +77,9 @@ class V4UpdateProtocolManagerFactoryImpl
std::unique_ptr<V4UpdateProtocolManager> CreateProtocolManager(
net::URLRequestContextGetter* request_context_getter,
const V4ProtocolConfig& config,
- const base::hash_map<UpdateListIdentifier, std::string>&
- current_list_states,
V4UpdateCallback callback) override {
- return std::unique_ptr<V4UpdateProtocolManager>(new V4UpdateProtocolManager(
- request_context_getter, config, current_list_states, callback));
+ return std::unique_ptr<V4UpdateProtocolManager>(
+ new V4UpdateProtocolManager(request_context_getter, config, callback));
}
private:
@@ -97,14 +95,12 @@ V4UpdateProtocolManagerFactory* V4UpdateProtocolManager::factory_ = NULL;
std::unique_ptr<V4UpdateProtocolManager> V4UpdateProtocolManager::Create(
net::URLRequestContextGetter* request_context_getter,
const V4ProtocolConfig& config,
- const base::hash_map<UpdateListIdentifier, std::string>&
- current_list_states,
V4UpdateCallback callback) {
if (!factory_) {
factory_ = new V4UpdateProtocolManagerFactoryImpl();
}
return factory_->CreateProtocolManager(request_context_getter, config,
- current_list_states, callback);
+ callback);
}
void V4UpdateProtocolManager::ResetUpdateErrors() {
@@ -115,10 +111,8 @@ void V4UpdateProtocolManager::ResetUpdateErrors() {
V4UpdateProtocolManager::V4UpdateProtocolManager(
net::URLRequestContextGetter* request_context_getter,
const V4ProtocolConfig& config,
- const base::hash_map<UpdateListIdentifier, std::string>&
- current_list_states,
V4UpdateCallback update_callback)
- : current_list_states_(current_list_states),
+ : store_state_map_(nullptr),
update_error_count_(0),
update_back_off_mult_(1),
next_update_interval_(base::TimeDelta::FromSeconds(
@@ -130,8 +124,6 @@ V4UpdateProtocolManager::V4UpdateProtocolManager(
update_callback_(update_callback) {
// Do not auto-schedule updates. Let the owner (V4LocalDatabaseManager) do it
// when it is ready to process updates.
- DVLOG(1) << "V4UpdateProtocolManager::V4UpdateProtocolManager: "
- << "next_update_interval_: " << next_update_interval_;
}
V4UpdateProtocolManager::~V4UpdateProtocolManager() {}
@@ -140,6 +132,12 @@ bool V4UpdateProtocolManager::IsUpdateScheduled() const {
return update_timer_.IsRunning();
}
+void V4UpdateProtocolManager::SetStoreStateMap(
+ const StoreStateMap* store_state_map) {
+ DCHECK(!store_state_map_);
+ store_state_map_ = store_state_map;
+}
+
void V4UpdateProtocolManager::ScheduleNextUpdate() {
ScheduleNextUpdateWithBackoff(false);
}
@@ -198,13 +196,13 @@ void V4UpdateProtocolManager::ScheduleNextUpdateAfterInterval(
&V4UpdateProtocolManager::IssueUpdateRequest);
}
+// static
std::string V4UpdateProtocolManager::GetBase64SerializedUpdateRequestProto(
- const base::hash_map<UpdateListIdentifier, std::string>&
- current_list_states) {
+ const StoreStateMap* store_state_map) {
// Build the request. Client info and client states are not added to the
// request protocol buffer. Client info is passed as params in the url.
FetchThreatListUpdatesRequest request;
- for (const auto& entry : current_list_states) {
+ for (const auto& entry : *store_state_map) {
const auto& list_to_update = entry.first;
const auto& state = entry.second;
ListUpdateRequest* list_update_request = request.add_list_update_requests();
@@ -277,7 +275,7 @@ void V4UpdateProtocolManager::IssueUpdateRequest() {
}
std::string req_base64 =
- GetBase64SerializedUpdateRequestProto(current_list_states_);
+ GetBase64SerializedUpdateRequestProto(store_state_map_);
GURL update_url;
net::HttpRequestHeaders headers;
GetUpdateUrlAndHeaders(req_base64, &update_url, &headers);
@@ -320,6 +318,10 @@ void V4UpdateProtocolManager::OnURLFetchComplete(
}
request_.reset();
+ DVLOG(1) << "OnURLFetchComplete: response_size: " << data.size();
+ UMA_HISTOGRAM_COUNTS("SafeBrowsing.V4UpdateResponseSizeKB",
+ data.size() / 1024);
+
// Invoke the callback with list_update_responses.
// The caller should update its state now, based on list_update_responses.
// The callback must call ScheduleNextUpdate() at the end to resume

Powered by Google App Engine
This is Rietveld 408576698