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

Unified Diff: components/safe_browsing_db/v4_store.cc

Issue 2103693002: SafeBrowsing PVer4: Send mutable response to the database and the stores (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@02_ReadFromDisk
Patch Set: 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_store.cc
diff --git a/components/safe_browsing_db/v4_store.cc b/components/safe_browsing_db/v4_store.cc
index a486c7f630eee4327ea55903fec6fd4e70dad588..5da0fa1530c48f0ba3d0605c99c5316d29e746b9 100644
--- a/components/safe_browsing_db/v4_store.cc
+++ b/components/safe_browsing_db/v4_store.cc
@@ -78,19 +78,19 @@ bool V4Store::Reset() {
}
void V4Store::ApplyUpdate(
- const ListUpdateResponse& response,
+ std::unique_ptr<ListUpdateResponse> response,
const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner,
UpdatedStoreReadyCallback callback) {
std::unique_ptr<V4Store> new_store(
new V4Store(this->task_runner_, this->store_path_));
// TODO(vakh): The new store currently only picks up the new state. Do more.
- new_store->state_ = response.new_client_state();
+ new_store->state_ = response->new_client_state();
// TODO(vakh): Merge the old store and the new update in new_store.
// Then, create a ListUpdateResponse containing RICE encoded hash-prefixes and
// response_type as FULL_UPDATE, and write that to disk.
- StoreWriteResult result = new_store->WriteToDisk(response);
+ StoreWriteResult result = new_store->WriteToDisk(std::move(response));
RecordStoreWriteResult(result);
// new_store is done updating, pass it to the callback.
@@ -142,15 +142,15 @@ StoreReadResult V4Store::ReadFromDisk() {
}
StoreWriteResult V4Store::WriteToDisk(
- const ListUpdateResponse& response) const {
+ std::unique_ptr<ListUpdateResponse> response) const {
// Do not write partial updates to the disk.
// After merging the updates, the ListUpdateResponse passed to this method
// should be a FULL_UPDATE.
- if (!response.has_response_type() ||
- response.response_type() != ListUpdateResponse::FULL_UPDATE) {
- DVLOG(1) << "response.has_response_type(): "
- << response.has_response_type();
- DVLOG(1) << "response.response_type(): " << response.response_type();
+ if (!response->has_response_type() ||
+ response->response_type() != ListUpdateResponse::FULL_UPDATE) {
+ DVLOG(1) << "response->has_response_type(): "
+ << response->has_response_type();
+ DVLOG(1) << "response->response_type(): " << response->response_type();
return INVALID_RESPONSE_TYPE_FAILURE;
}
@@ -162,7 +162,7 @@ StoreWriteResult V4Store::WriteToDisk(
file_format.set_version_number(kFileVersion);
ListUpdateResponse* response_to_write =
file_format.mutable_list_update_response();
- *response_to_write = response;
+ response_to_write->Swap(response.get());
std::string file_format_string;
file_format.SerializeToString(&file_format_string);
size_t written = base::WriteFile(new_filename, file_format_string.data(),

Powered by Google App Engine
This is Rietveld 408576698