Commit 53aeef9b authored by avi's avatar avi Committed by Commit bot

Remove stl_util's deletion function use from components/history/.

BUG=555865

Review-Url: https://codereview.chromium.org/2441223002
Cr-Commit-Position: refs/heads/master@{#427123}
parent b5c08206
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/json/json_reader.h" #include "base/json/json_reader.h"
#include "base/json/json_writer.h" #include "base/json/json_writer.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/values.h" #include "base/values.h"
...@@ -336,10 +336,6 @@ WebHistoryService::WebHistoryService( ...@@ -336,10 +336,6 @@ WebHistoryService::WebHistoryService(
} }
WebHistoryService::~WebHistoryService() { WebHistoryService::~WebHistoryService() {
base::STLDeleteElements(&pending_expire_requests_);
base::STLDeleteElements(&pending_audio_history_requests_);
base::STLDeleteElements(&pending_web_and_app_activity_requests_);
base::STLDeleteElements(&pending_other_forms_of_browsing_history_requests_);
} }
void WebHistoryService::AddObserver(WebHistoryServiceObserver* observer) { void WebHistoryService::AddObserver(WebHistoryServiceObserver* observer) {
...@@ -430,7 +426,7 @@ void WebHistoryService::ExpireHistory( ...@@ -430,7 +426,7 @@ void WebHistoryService::ExpireHistory(
std::unique_ptr<Request> request(CreateRequest(url, completion_callback)); std::unique_ptr<Request> request(CreateRequest(url, completion_callback));
request->SetPostData(post_data); request->SetPostData(post_data);
Request* request_ptr = request.get(); Request* request_ptr = request.get();
pending_expire_requests_.insert(request.release()); pending_expire_requests_[request_ptr] = std::move(request);
request_ptr->Start(); request_ptr->Start();
} }
...@@ -457,7 +453,8 @@ void WebHistoryService::GetAudioHistoryEnabled( ...@@ -457,7 +453,8 @@ void WebHistoryService::GetAudioHistoryEnabled(
GURL url(kHistoryAudioHistoryUrl); GURL url(kHistoryAudioHistoryUrl);
std::unique_ptr<Request> request(CreateRequest(url, completion_callback)); std::unique_ptr<Request> request(CreateRequest(url, completion_callback));
request->Start(); request->Start();
pending_audio_history_requests_.insert(request.release()); Request* request_ptr = request.get();
pending_audio_history_requests_[request_ptr] = std::move(request);
} }
void WebHistoryService::SetAudioHistoryEnabled( void WebHistoryService::SetAudioHistoryEnabled(
...@@ -481,7 +478,8 @@ void WebHistoryService::SetAudioHistoryEnabled( ...@@ -481,7 +478,8 @@ void WebHistoryService::SetAudioHistoryEnabled(
request->SetPostData(post_data); request->SetPostData(post_data);
request->Start(); request->Start();
pending_audio_history_requests_.insert(request.release()); Request* request_ptr = request.get();
pending_audio_history_requests_[request_ptr] = std::move(request);
} }
size_t WebHistoryService::GetNumberOfPendingAudioHistoryRequests() { size_t WebHistoryService::GetNumberOfPendingAudioHistoryRequests() {
...@@ -498,7 +496,7 @@ void WebHistoryService::QueryWebAndAppActivity( ...@@ -498,7 +496,7 @@ void WebHistoryService::QueryWebAndAppActivity(
GURL url(kQueryWebAndAppActivityUrl); GURL url(kQueryWebAndAppActivityUrl);
Request* request = CreateRequest(url, completion_callback); Request* request = CreateRequest(url, completion_callback);
pending_web_and_app_activity_requests_.insert(request); pending_web_and_app_activity_requests_[request] = base::WrapUnique(request);
request->Start(); request->Start();
} }
...@@ -528,7 +526,8 @@ void WebHistoryService::QueryOtherFormsOfBrowsingHistory( ...@@ -528,7 +526,8 @@ void WebHistoryService::QueryOtherFormsOfBrowsingHistory(
channel, ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET); channel, ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET);
request->SetUserAgent(user_agent); request->SetUserAgent(user_agent);
pending_other_forms_of_browsing_history_requests_.insert(request); pending_other_forms_of_browsing_history_requests_[request] =
base::WrapUnique(request);
// Set the request protobuf. // Set the request protobuf.
sync_pb::HistoryStatusRequest request_proto; sync_pb::HistoryStatusRequest request_proto;
...@@ -554,8 +553,9 @@ void WebHistoryService::ExpireHistoryCompletionCallback( ...@@ -554,8 +553,9 @@ void WebHistoryService::ExpireHistoryCompletionCallback(
const WebHistoryService::ExpireWebHistoryCallback& callback, const WebHistoryService::ExpireWebHistoryCallback& callback,
WebHistoryService::Request* request, WebHistoryService::Request* request,
bool success) { bool success) {
std::unique_ptr<Request> request_ptr =
std::move(pending_expire_requests_[request]);
pending_expire_requests_.erase(request); pending_expire_requests_.erase(request);
std::unique_ptr<Request> request_ptr(request);
std::unique_ptr<base::DictionaryValue> response_value; std::unique_ptr<base::DictionaryValue> response_value;
if (success) { if (success) {
...@@ -576,13 +576,14 @@ void WebHistoryService::AudioHistoryCompletionCallback( ...@@ -576,13 +576,14 @@ void WebHistoryService::AudioHistoryCompletionCallback(
const WebHistoryService::AudioWebHistoryCallback& callback, const WebHistoryService::AudioWebHistoryCallback& callback,
WebHistoryService::Request* request, WebHistoryService::Request* request,
bool success) { bool success) {
std::unique_ptr<Request> request_ptr =
std::move(pending_audio_history_requests_[request]);
pending_audio_history_requests_.erase(request); pending_audio_history_requests_.erase(request);
std::unique_ptr<WebHistoryService::Request> request_ptr(request);
std::unique_ptr<base::DictionaryValue> response_value; std::unique_ptr<base::DictionaryValue> response_value;
bool enabled_value = false; bool enabled_value = false;
if (success) { if (success) {
response_value = ReadResponse(request_ptr.get()); response_value = ReadResponse(request);
if (response_value) if (response_value)
response_value->GetBoolean("history_recording_enabled", &enabled_value); response_value->GetBoolean("history_recording_enabled", &enabled_value);
} }
...@@ -597,8 +598,9 @@ void WebHistoryService::QueryWebAndAppActivityCompletionCallback( ...@@ -597,8 +598,9 @@ void WebHistoryService::QueryWebAndAppActivityCompletionCallback(
const WebHistoryService::QueryWebAndAppActivityCallback& callback, const WebHistoryService::QueryWebAndAppActivityCallback& callback,
WebHistoryService::Request* request, WebHistoryService::Request* request,
bool success) { bool success) {
std::unique_ptr<Request> request_ptr =
std::move(pending_web_and_app_activity_requests_[request]);
pending_web_and_app_activity_requests_.erase(request); pending_web_and_app_activity_requests_.erase(request);
std::unique_ptr<Request> request_ptr(request);
std::unique_ptr<base::DictionaryValue> response_value; std::unique_ptr<base::DictionaryValue> response_value;
bool web_and_app_activity_enabled = false; bool web_and_app_activity_enabled = false;
...@@ -618,8 +620,9 @@ void WebHistoryService::QueryOtherFormsOfBrowsingHistoryCompletionCallback( ...@@ -618,8 +620,9 @@ void WebHistoryService::QueryOtherFormsOfBrowsingHistoryCompletionCallback(
const WebHistoryService::QueryOtherFormsOfBrowsingHistoryCallback& callback, const WebHistoryService::QueryOtherFormsOfBrowsingHistoryCallback& callback,
WebHistoryService::Request* request, WebHistoryService::Request* request,
bool success) { bool success) {
std::unique_ptr<Request> request_ptr =
std::move(pending_other_forms_of_browsing_history_requests_[request]);
pending_other_forms_of_browsing_history_requests_.erase(request); pending_other_forms_of_browsing_history_requests_.erase(request);
std::unique_ptr<Request> request_ptr(request);
bool has_other_forms_of_browsing_history = false; bool has_other_forms_of_browsing_history = false;
if (success && request->GetResponseCode() == net::HTTP_OK) { if (success && request->GetResponseCode() == net::HTTP_OK) {
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
#include <stddef.h> #include <stddef.h>
#include <set> #include <map>
#include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -212,18 +213,20 @@ class WebHistoryService : public KeyedService { ...@@ -212,18 +213,20 @@ class WebHistoryService : public KeyedService {
// Pending expiration requests to be canceled if not complete by profile // Pending expiration requests to be canceled if not complete by profile
// shutdown. // shutdown.
std::set<Request*> pending_expire_requests_; std::map<Request*, std::unique_ptr<Request>> pending_expire_requests_;
// Pending requests to be canceled if not complete by profile shutdown. // Pending requests to be canceled if not complete by profile shutdown.
std::set<Request*> pending_audio_history_requests_; std::map<Request*, std::unique_ptr<Request>> pending_audio_history_requests_;
// Pending web and app activity queries to be canceled if not complete by // Pending web and app activity queries to be canceled if not complete by
// profile shutdown. // profile shutdown.
std::set<Request*> pending_web_and_app_activity_requests_; std::map<Request*, std::unique_ptr<Request>>
pending_web_and_app_activity_requests_;
// Pending queries for other forms of browsing history to be canceled if not // Pending queries for other forms of browsing history to be canceled if not
// complete by profile shutdown. // complete by profile shutdown.
std::set<Request*> pending_other_forms_of_browsing_history_requests_; std::map<Request*, std::unique_ptr<Request>>
pending_other_forms_of_browsing_history_requests_;
// Observers. // Observers.
base::ObserverList<WebHistoryServiceObserver, true> observer_list_; base::ObserverList<WebHistoryServiceObserver, true> observer_list_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment