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

Unified Diff: extensions/browser/api/web_request/web_request_event_details.cc

Issue 2899743002: Remove raw base::DictionaryValue::Set in //extensions (Closed)
Patch Set: Rebase Created 3 years, 7 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: extensions/browser/api/web_request/web_request_event_details.cc
diff --git a/extensions/browser/api/web_request/web_request_event_details.cc b/extensions/browser/api/web_request/web_request_event_details.cc
index 8a3e87473763872143e6aea6c18fcb049d6324c7..f4be1d3b8d72ff6520fd648a028b9d2302376095 100644
--- a/extensions/browser/api/web_request/web_request_event_details.cc
+++ b/extensions/browser/api/web_request/web_request_event_details.cc
@@ -4,7 +4,10 @@
#include "extensions/browser/api/web_request/web_request_event_details.h"
+#include <utility>
+
#include "base/callback.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
@@ -126,10 +129,10 @@ void WebRequestEventDetails::SetAuthInfo(
dict_.SetString(keys::kSchemeKey, auth_info.scheme);
if (!auth_info.realm.empty())
dict_.SetString(keys::kRealmKey, auth_info.realm);
- base::DictionaryValue* challenger = new base::DictionaryValue();
+ auto challenger = base::MakeUnique<base::DictionaryValue>();
challenger->SetString(keys::kHostKey, auth_info.challenger.host());
challenger->SetInteger(keys::kPortKey, auth_info.challenger.port());
- dict_.Set(keys::kChallengerKey, challenger);
+ dict_.Set(keys::kChallengerKey, std::move(challenger));
}
void WebRequestEventDetails::SetResponseHeaders(
@@ -194,11 +197,14 @@ std::unique_ptr<base::DictionaryValue> WebRequestEventDetails::GetFilteredDict(
int extra_info_spec) const {
std::unique_ptr<base::DictionaryValue> result = dict_.CreateDeepCopy();
if ((extra_info_spec & ExtraInfoSpec::REQUEST_BODY) && request_body_)
Devlin 2017/06/02 15:38:48 since the bodies of these if's are now multi-line,
jdoerrie 2017/06/06 12:40:23 Done.
- result->Set(keys::kRequestBodyKey, request_body_->CreateDeepCopy());
+ result->Set(keys::kRequestBodyKey,
+ base::MakeUnique<base::Value>(*request_body_));
Devlin 2017/06/02 15:38:48 Is the copy-constructor preferred over CreateDeepC
vabr (Chromium) 2017/06/03 11:14:52 Indeed, CreateDeepCopy is deprecated in favour of
Devlin 2017/06/05 13:27:33 SG. Can we add a comment to DictionaryValue::Crea
jdoerrie 2017/06/06 12:40:23 Done: http://crrev.com/c/525792
if ((extra_info_spec & ExtraInfoSpec::REQUEST_HEADERS) && request_headers_)
- result->Set(keys::kRequestHeadersKey, request_headers_->CreateDeepCopy());
+ result->Set(keys::kRequestHeadersKey,
+ base::MakeUnique<base::Value>(*request_headers_));
if ((extra_info_spec & ExtraInfoSpec::RESPONSE_HEADERS) && response_headers_)
- result->Set(keys::kResponseHeadersKey, response_headers_->CreateDeepCopy());
+ result->Set(keys::kResponseHeadersKey,
+ base::MakeUnique<base::Value>(*response_headers_));
return result;
}

Powered by Google App Engine
This is Rietveld 408576698