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

Unified Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 2503713004: Avoid string copies when determining approximate memory usage in RDHI (Closed)
Patch Set: rdsmith review and fix unit tests Created 4 years, 1 month 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: content/browser/loader/resource_dispatcher_host_impl.cc
diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc
index 6b3e7706856ae695d8ca4f5b78da5bc023248c94..d6a67518b15accdc8f7ecde7f9830b22c94a4571 100644
--- a/content/browser/loader/resource_dispatcher_host_impl.cc
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc
@@ -100,6 +100,7 @@
#include "net/base/upload_data_stream.h"
#include "net/cert/cert_status_flags.h"
#include "net/cookies/cookie_monster.h"
+#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_response_info.h"
#include "net/ssl/client_cert_store.h"
@@ -113,6 +114,7 @@
#include "storage/browser/blob/shareable_file_reference.h"
#include "storage/browser/fileapi/file_permission_policy.h"
#include "storage/browser/fileapi/file_system_context.h"
+#include "url/third_party/mozilla/url_parse.h"
#include "url/url_constants.h"
using base::Time;
@@ -2330,10 +2332,14 @@ int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(
// The following fields should be a minor size contribution (experimentally
// on the order of 100). However since they are variable length, it could
// in theory be a sizeable contribution.
- int strings_cost = request->extra_request_headers().ToString().size() +
- request->original_url().spec().size() +
- request->referrer().size() +
- request->method().size();
+ int strings_cost = 0;
+ for (net::HttpRequestHeaders::Iterator it(request->extra_request_headers());
+ it.GetNext();) {
+ strings_cost += it.name().length() + it.value().length();
+ }
+ strings_cost +=
+ request->original_url().parsed_for_possibly_invalid_spec().Length() +
+ request->referrer().size() + request->method().size();
// Note that this expression will typically be dominated by:
// |kAvgBytesPerOutstandingRequest|.
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | content/browser/loader/resource_dispatcher_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698