blob: 05bcf7780832738f9c370d93c98f2ab5ab890594 [file] [log] [blame]
[email protected]9045b8822012-01-13 20:35:351// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]ac039522010-06-15 16:39:442// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/net/chrome_network_delegate.h"
6
[email protected]eac11e12013-03-19 22:04:327#include <stdlib.h>
8
[email protected]d1208ba32012-11-08 11:10:339#include <vector>
10
[email protected]d8e4f132012-09-06 04:28:0511#include "base/base_paths.h"
[email protected]4aca5db2013-08-17 00:51:5612#include "base/debug/trace_event.h"
[email protected]7a299a92012-10-24 23:54:5013#include "base/logging.h"
14#include "base/metrics/histogram.h"
[email protected]d8e4f132012-09-06 04:28:0515#include "base/path_service.h"
[email protected]1ab137b2013-03-21 03:33:1816#include "base/prefs/pref_member.h"
[email protected]3853a4c2013-02-11 17:15:5717#include "base/prefs/pref_service.h"
[email protected]3ea1b182013-02-08 22:38:4118#include "base/strings/string_number_conversions.h"
[email protected]1988e1c2013-02-28 20:27:4219#include "base/strings/string_split.h"
[email protected]069c49162013-09-11 20:46:3520#include "base/time/time.h"
[email protected]6baff0b52012-03-06 01:30:1821#include "chrome/browser/browser_process.h"
[email protected]9c8ae8c2012-03-09 13:13:3522#include "chrome/browser/content_settings/cookie_settings.h"
23#include "chrome/browser/content_settings/tab_specific_content_settings.h"
[email protected]8523ba52011-05-22 19:00:5824#include "chrome/browser/custom_handlers/protocol_handler_registry.h"
[email protected]aa84a7e2012-03-15 21:29:0625#include "chrome/browser/extensions/api/proxy/proxy_api.h"
[email protected]2b33dcd02012-03-18 01:34:1626#include "chrome/browser/extensions/api/web_request/web_request_api.h"
[email protected]5a38dfd2012-07-23 23:22:1027#include "chrome/browser/extensions/event_router_forwarder.h"
[email protected]be93bba02012-10-24 16:44:0328#include "chrome/browser/extensions/extension_system.h"
[email protected]d1208ba32012-11-08 11:10:3329#include "chrome/browser/google/google_util.h"
[email protected]0d36d1e2013-09-24 04:25:2830#include "chrome/browser/net/chrome_network_data_saving_metrics.h"
[email protected]3620bbc2013-10-05 05:07:2331#include "chrome/browser/net/client_hints.h"
[email protected]f53b4802012-12-20 17:04:2332#include "chrome/browser/net/connect_interceptor.h"
[email protected]a9e0d1412012-08-20 22:13:0133#include "chrome/browser/net/load_time_stats.h"
[email protected]6f4b4b42012-08-27 21:59:0734#include "chrome/browser/performance_monitor/performance_monitor.h"
[email protected]6baff0b52012-03-06 01:30:1835#include "chrome/browser/profiles/profile_manager.h"
[email protected]8523ba52011-05-22 19:00:5836#include "chrome/browser/task_manager/task_manager.h"
[email protected]0a8db0d2011-04-13 15:15:4037#include "chrome/common/pref_names.h"
[email protected]a1d4ab072012-06-07 13:21:1538#include "chrome/common/url_constants.h"
[email protected]c38831a12011-10-28 12:44:4939#include "content/public/browser/browser_thread.h"
[email protected]9c1662b2012-03-06 15:44:3340#include "content/public/browser/render_view_host.h"
[email protected]9c8ae8c2012-03-09 13:13:3541#include "content/public/browser/resource_request_info.h"
[email protected]38427a12013-11-09 17:34:2042#include "extensions/browser/info_map.h"
[email protected]98b6d942013-11-10 00:34:0743#include "extensions/browser/process_manager.h"
[email protected]885c0e92012-11-13 20:27:4244#include "extensions/common/constants.h"
[email protected]82b42302011-04-20 16:28:1645#include "net/base/host_port_pair.h"
[email protected]8202d0c2011-02-23 08:31:1446#include "net/base/net_errors.h"
[email protected]6a5f77c32011-09-04 19:19:5947#include "net/base/net_log.h"
[email protected]5b9bc352012-07-18 13:13:3448#include "net/cookies/canonical_cookie.h"
49#include "net/cookies/cookie_options.h"
[email protected]ac039522010-06-15 16:39:4450#include "net/http/http_request_headers.h"
[email protected]48944382011-04-23 13:28:1651#include "net/http/http_response_headers.h"
[email protected]aa28181e2012-06-13 00:53:5852#include "net/socket_stream/socket_stream.h"
[email protected]d05ef99c2011-02-01 21:38:1653#include "net/url_request/url_request.h"
54
[email protected]4c219e22012-05-05 19:41:0455#if defined(OS_CHROMEOS)
[email protected]288538482012-09-06 21:09:3556#include "base/command_line.h"
[email protected]49c4cf852013-09-27 19:28:2457#include "base/sys_info.h"
[email protected]288538482012-09-06 21:09:3558#include "chrome/common/chrome_switches.h"
[email protected]4c219e22012-05-05 19:41:0459#endif
60
[email protected]3e598ff12011-09-06 11:22:3461#if defined(ENABLE_CONFIGURATION_POLICY)
[email protected]d0820562013-12-17 23:58:5462#include "components/policy/core/common/url_blacklist_manager.h"
[email protected]3e598ff12011-09-06 11:22:3463#endif
64
[email protected]631bb742011-11-02 11:29:3965using content::BrowserThread;
[email protected]eaabba22012-03-07 15:02:1166using content::RenderViewHost;
[email protected]ea114722012-03-12 01:11:2567using content::ResourceRequestInfo;
[email protected]631bb742011-11-02 11:29:3968
[email protected]d8e4f132012-09-06 04:28:0569// By default we don't allow access to all file:// urls on ChromeOS and
70// Android.
71#if defined(OS_CHROMEOS) || defined(OS_ANDROID)
[email protected]4c219e22012-05-05 19:41:0472bool ChromeNetworkDelegate::g_allow_file_access_ = false;
73#else
74bool ChromeNetworkDelegate::g_allow_file_access_ = true;
75#endif
76
[email protected]c4a7df82012-08-09 22:48:4677// This remains false unless the --disable-extensions-http-throttling
78// flag is passed to the browser.
79bool ChromeNetworkDelegate::g_never_throttle_requests_ = false;
80
[email protected]d05ef99c2011-02-01 21:38:1681namespace {
82
[email protected]9d8cfb682012-09-13 16:48:0483const char kDNTHeader[] = "DNT";
84
[email protected]8202d0c2011-02-23 08:31:1485// If the |request| failed due to problems with a proxy, forward the error to
86// the proxy extension API.
[email protected]0651b812011-02-24 00:22:5087void ForwardProxyErrors(net::URLRequest* request,
[email protected]5a38dfd2012-07-23 23:22:1088 extensions::EventRouterForwarder* event_router,
[email protected]673514522011-07-13 18:17:1889 void* profile) {
[email protected]8202d0c2011-02-23 08:31:1490 if (request->status().status() == net::URLRequestStatus::FAILED) {
[email protected]d0cc35b2011-09-08 12:02:0591 switch (request->status().error()) {
[email protected]8202d0c2011-02-23 08:31:1492 case net::ERR_PROXY_AUTH_UNSUPPORTED:
93 case net::ERR_PROXY_CONNECTION_FAILED:
94 case net::ERR_TUNNEL_CONNECTION_FAILED:
[email protected]c454fe672012-03-12 21:18:0195 extensions::ProxyEventRouter::GetInstance()->OnProxyError(
[email protected]d0cc35b2011-09-08 12:02:0596 event_router, profile, request->status().error());
[email protected]8202d0c2011-02-23 08:31:1497 }
98 }
99}
100
[email protected]d1208ba32012-11-08 11:10:33101// Returns whether a URL parameter, |first_parameter| (e.g. foo=bar), has the
102// same key as the the |second_parameter| (e.g. foo=baz). Both parameters
103// must be in key=value form.
104bool HasSameParameterKey(const std::string& first_parameter,
105 const std::string& second_parameter) {
106 DCHECK(second_parameter.find("=") != std::string::npos);
107 // Prefix for "foo=bar" is "foo=".
108 std::string parameter_prefix = second_parameter.substr(
109 0, second_parameter.find("=") + 1);
110 return StartsWithASCII(first_parameter, parameter_prefix, false);
111}
112
113// Examines the query string containing parameters and adds the necessary ones
114// so that SafeSearch is active. |query| is the string to examine and the
115// return value is the |query| string modified such that SafeSearch is active.
116std::string AddSafeSearchParameters(const std::string& query) {
117 std::vector<std::string> new_parameters;
118 std::string safe_parameter = chrome::kSafeSearchSafeParameter;
119 std::string ssui_parameter = chrome::kSafeSearchSsuiParameter;
120
121 std::vector<std::string> parameters;
122 base::SplitString(query, '&', &parameters);
123
124 std::vector<std::string>::iterator it;
125 for (it = parameters.begin(); it < parameters.end(); ++it) {
126 if (!HasSameParameterKey(*it, safe_parameter) &&
127 !HasSameParameterKey(*it, ssui_parameter)) {
128 new_parameters.push_back(*it);
129 }
130 }
131
132 new_parameters.push_back(safe_parameter);
133 new_parameters.push_back(ssui_parameter);
134 return JoinString(new_parameters, '&');
135}
136
137// If |request| is a request to Google Web Search the function
138// enforces that the SafeSearch query parameters are set to active.
139// Sets the query part of |new_url| with the new value of the parameters.
140void ForceGoogleSafeSearch(net::URLRequest* request,
141 GURL* new_url) {
[email protected]c02f79d2013-06-27 21:46:47142 if (!google_util::IsGoogleSearchUrl(request->url()) &&
143 !google_util::IsGoogleHomePageUrl(request->url()))
[email protected]d1208ba32012-11-08 11:10:33144 return;
145
146 std::string query = request->url().query();
147 std::string new_query = AddSafeSearchParameters(query);
148 if (query == new_query)
149 return;
150
151 GURL::Replacements replacements;
152 replacements.SetQueryStr(new_query);
153 *new_url = request->url().ReplaceComponents(replacements);
154}
155
156// Gets called when the extensions finish work on the URL. If the extensions
157// did not do a redirect (so |new_url| is empty) then we enforce the
158// SafeSearch parameters. Otherwise we will get called again after the
159// redirect and we enforce SafeSearch then.
160void ForceGoogleSafeSearchCallbackWrapper(
161 const net::CompletionCallback& callback,
162 net::URLRequest* request,
163 GURL* new_url,
164 int rv) {
165 if (rv == net::OK && new_url->is_empty())
166 ForceGoogleSafeSearch(request, new_url);
167 callback.Run(rv);
168}
169
[email protected]6baff0b52012-03-06 01:30:18170enum RequestStatus { REQUEST_STARTED, REQUEST_DONE };
171
[email protected]98b6d942013-11-10 00:34:07172// Notifies the extensions::ProcessManager that a request has started or stopped
[email protected]6baff0b52012-03-06 01:30:18173// for a particular RenderView.
174void NotifyEPMRequestStatus(RequestStatus status,
175 void* profile_id,
176 int process_id,
177 int render_view_id) {
178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
179 Profile* profile = reinterpret_cast<Profile*>(profile_id);
180 if (!g_browser_process->profile_manager()->IsValidProfile(profile))
181 return;
182
[email protected]98b6d942013-11-10 00:34:07183 extensions::ProcessManager* process_manager =
[email protected]be93bba02012-10-24 16:44:03184 extensions::ExtensionSystem::Get(profile)->process_manager();
[email protected]e5775a52012-03-17 04:59:57185 // This may be NULL in unit tests.
[email protected]98b6d942013-11-10 00:34:07186 if (!process_manager)
[email protected]e5775a52012-03-17 04:59:57187 return;
188
[email protected]6baff0b52012-03-06 01:30:18189 // Will be NULL if the request was not issued on behalf of a renderer (e.g. a
190 // system-level request).
[email protected]d3e898e2012-03-14 03:45:08191 RenderViewHost* render_view_host =
192 RenderViewHost::FromID(process_id, render_view_id);
[email protected]e5775a52012-03-17 04:59:57193 if (render_view_host) {
[email protected]6baff0b52012-03-06 01:30:18194 if (status == REQUEST_STARTED) {
[email protected]98b6d942013-11-10 00:34:07195 process_manager->OnNetworkRequestStarted(render_view_host);
[email protected]6baff0b52012-03-06 01:30:18196 } else if (status == REQUEST_DONE) {
[email protected]98b6d942013-11-10 00:34:07197 process_manager->OnNetworkRequestDone(render_view_host);
[email protected]6baff0b52012-03-06 01:30:18198 } else {
199 NOTREACHED();
200 }
201 }
202}
203
204void ForwardRequestStatus(
205 RequestStatus status, net::URLRequest* request, void* profile_id) {
[email protected]ea114722012-03-12 01:11:25206 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
207 if (!info)
208 return;
209
[email protected]6baff0b52012-03-06 01:30:18210 int process_id, render_view_id;
[email protected]ea114722012-03-12 01:11:25211 if (info->GetAssociatedRenderView(&process_id, &render_view_id)) {
[email protected]6baff0b52012-03-06 01:30:18212 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
213 base::Bind(&NotifyEPMRequestStatus,
214 status, profile_id, process_id, render_view_id));
215 }
216}
217
[email protected]828eab22013-12-10 22:42:38218void UpdateContentLengthPrefs(
219 int received_content_length,
220 int original_content_length,
[email protected]b7796462013-12-12 19:42:34221 chrome_browser_net::DataReductionRequestType data_reduction_type,
222 Profile* profile) {
[email protected]7a299a92012-10-24 23:54:50223 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
224 DCHECK_GE(received_content_length, 0);
225 DCHECK_GE(original_content_length, 0);
226
[email protected]a09159a2012-11-29 12:51:48227 // Can be NULL in a unit test.
228 if (!g_browser_process)
229 return;
230
[email protected]7a299a92012-10-24 23:54:50231 PrefService* prefs = g_browser_process->local_state();
[email protected]a09159a2012-11-29 12:51:48232 if (!prefs)
233 return;
[email protected]7a299a92012-10-24 23:54:50234
[email protected]b7796462013-12-12 19:42:34235 // Ignore off-the-record data.
236 if (!g_browser_process->profile_manager()->IsValidProfile(profile) ||
237 profile->IsOffTheRecord()) {
238 return;
239 }
[email protected]0d36d1e2013-09-24 04:25:28240#if defined(OS_ANDROID)
[email protected]b1d5ed52013-12-18 02:34:56241 // If Android ever goes multi profile, the profile should be passed so that
242 // the browser preference will be taken.
[email protected]0d36d1e2013-09-24 04:25:28243 bool with_data_reduction_proxy_enabled =
[email protected]b1d5ed52013-12-18 02:34:56244 ProfileManager::GetActiveUserProfile()->GetPrefs()->GetBoolean(
245 prefs::kSpdyProxyAuthEnabled);
[email protected]0d36d1e2013-09-24 04:25:28246#else
247 bool with_data_reduction_proxy_enabled = false;
[email protected]eac11e12013-03-19 22:04:32248#endif
[email protected]0d36d1e2013-09-24 04:25:28249
250 chrome_browser_net::UpdateContentLengthPrefs(
251 received_content_length,
252 original_content_length,
253 with_data_reduction_proxy_enabled,
[email protected]828eab22013-12-10 22:42:38254 data_reduction_type, prefs);
[email protected]7a299a92012-10-24 23:54:50255}
256
[email protected]828eab22013-12-10 22:42:38257void StoreAccumulatedContentLength(
258 int received_content_length,
259 int original_content_length,
[email protected]b7796462013-12-12 19:42:34260 chrome_browser_net::DataReductionRequestType data_reduction_type,
261 Profile* profile) {
[email protected]7a299a92012-10-24 23:54:50262 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
263 base::Bind(&UpdateContentLengthPrefs,
[email protected]2db93e42013-08-07 17:40:41264 received_content_length, original_content_length,
[email protected]b7796462013-12-12 19:42:34265 data_reduction_type, profile));
[email protected]7a299a92012-10-24 23:54:50266}
267
268void RecordContentLengthHistograms(
[email protected]f81a5ee2013-06-20 21:08:49269 int64 received_content_length,
270 int64 original_content_length,
271 const base::TimeDelta& freshness_lifetime) {
[email protected]0d36d1e2013-09-24 04:25:28272#if defined(OS_ANDROID)
[email protected]7a299a92012-10-24 23:54:50273 // Add the current resource to these histograms only when a valid
274 // X-Original-Content-Length header is present.
275 if (original_content_length >= 0) {
276 UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthWithValidOCL",
277 received_content_length);
278 UMA_HISTOGRAM_COUNTS("Net.HttpOriginalContentLengthWithValidOCL",
279 original_content_length);
280 UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthDifferenceWithValidOCL",
281 original_content_length - received_content_length);
282 } else {
283 // Presume the original content length is the same as the received content
284 // length if the X-Original-Content-Header is not present.
285 original_content_length = received_content_length;
286 }
287 UMA_HISTOGRAM_COUNTS("Net.HttpContentLength", received_content_length);
288 UMA_HISTOGRAM_COUNTS("Net.HttpOriginalContentLength",
289 original_content_length);
290 UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthDifference",
291 original_content_length - received_content_length);
[email protected]f81a5ee2013-06-20 21:08:49292 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.HttpContentFreshnessLifetime",
293 freshness_lifetime.InSeconds(),
294 base::TimeDelta::FromHours(1).InSeconds(),
295 base::TimeDelta::FromDays(30).InSeconds(),
296 100);
297 if (freshness_lifetime.InSeconds() <= 0)
298 return;
299 UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthCacheable",
300 received_content_length);
301 if (freshness_lifetime.InHours() < 4)
302 return;
303 UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthCacheable4Hours",
304 received_content_length);
305
306 if (freshness_lifetime.InHours() < 24)
307 return;
308 UMA_HISTOGRAM_COUNTS("Net.HttpContentLengthCacheable24Hours",
309 received_content_length);
[email protected]0d36d1e2013-09-24 04:25:28310#endif // defined(OS_ANDROID)
[email protected]7a299a92012-10-24 23:54:50311}
312
[email protected]d05ef99c2011-02-01 21:38:16313} // namespace
[email protected]ac039522010-06-15 16:39:44314
[email protected]0651b812011-02-24 00:22:50315ChromeNetworkDelegate::ChromeNetworkDelegate(
[email protected]5a38dfd2012-07-23 23:22:10316 extensions::EventRouterForwarder* event_router,
[email protected]a09159a2012-11-29 12:51:48317 BooleanPrefMember* enable_referrers)
[email protected]3ce02412011-03-01 12:01:15318 : event_router_(event_router),
[email protected]a09159a2012-11-29 12:51:48319 profile_(NULL),
[email protected]6a5f77c32011-09-04 19:19:59320 enable_referrers_(enable_referrers),
[email protected]a09159a2012-11-29 12:51:48321 enable_do_not_track_(NULL),
322 force_google_safe_search_(NULL),
323 url_blacklist_manager_(NULL),
324 load_time_stats_(NULL),
[email protected]7a299a92012-10-24 23:54:50325 received_content_length_(0),
326 original_content_length_(0) {
[email protected]4b50cb52011-03-10 00:29:37327 DCHECK(event_router);
[email protected]0a8db0d2011-04-13 15:15:40328 DCHECK(enable_referrers);
[email protected]0651b812011-02-24 00:22:50329}
330
[email protected]ac039522010-06-15 16:39:44331ChromeNetworkDelegate::~ChromeNetworkDelegate() {}
332
[email protected]a09159a2012-11-29 12:51:48333void ChromeNetworkDelegate::set_extension_info_map(
[email protected]38427a12013-11-09 17:34:20334 extensions::InfoMap* extension_info_map) {
[email protected]a09159a2012-11-29 12:51:48335 extension_info_map_ = extension_info_map;
336}
337
338void ChromeNetworkDelegate::set_cookie_settings(
339 CookieSettings* cookie_settings) {
340 cookie_settings_ = cookie_settings;
341}
342
[email protected]f53b4802012-12-20 17:04:23343void ChromeNetworkDelegate::set_predictor(
344 chrome_browser_net::Predictor* predictor) {
345 connect_interceptor_.reset(
346 new chrome_browser_net::ConnectInterceptor(predictor));
347}
348
[email protected]3620bbc2013-10-05 05:07:23349void ChromeNetworkDelegate::SetEnableClientHints() {
350 client_hints_.reset(new ClientHints());
351 client_hints_->Init();
352}
353
[email protected]c4a7df82012-08-09 22:48:46354// static
[email protected]a1d4ab072012-06-07 13:21:15355void ChromeNetworkDelegate::NeverThrottleRequests() {
[email protected]c4a7df82012-08-09 22:48:46356 g_never_throttle_requests_ = true;
[email protected]a1d4ab072012-06-07 13:21:15357}
358
[email protected]0a8db0d2011-04-13 15:15:40359// static
[email protected]9d8cfb682012-09-13 16:48:04360void ChromeNetworkDelegate::InitializePrefsOnUIThread(
[email protected]0a8db0d2011-04-13 15:15:40361 BooleanPrefMember* enable_referrers,
[email protected]9d8cfb682012-09-13 16:48:04362 BooleanPrefMember* enable_do_not_track,
[email protected]d1208ba32012-11-08 11:10:33363 BooleanPrefMember* force_google_safe_search,
[email protected]0a8db0d2011-04-13 15:15:40364 PrefService* pref_service) {
365 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
[email protected]96a5c342012-12-04 18:14:02366 enable_referrers->Init(prefs::kEnableReferrers, pref_service);
[email protected]6a1c98e02012-10-24 21:49:43367 enable_referrers->MoveToThread(
368 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
[email protected]9d8cfb682012-09-13 16:48:04369 if (enable_do_not_track) {
[email protected]96a5c342012-12-04 18:14:02370 enable_do_not_track->Init(prefs::kEnableDoNotTrack, pref_service);
[email protected]6a1c98e02012-10-24 21:49:43371 enable_do_not_track->MoveToThread(
372 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
[email protected]9d8cfb682012-09-13 16:48:04373 }
[email protected]d1208ba32012-11-08 11:10:33374 if (force_google_safe_search) {
[email protected]96a5c342012-12-04 18:14:02375 force_google_safe_search->Init(prefs::kForceSafeSearch, pref_service);
[email protected]d1208ba32012-11-08 11:10:33376 force_google_safe_search->MoveToThread(
377 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
378 }
[email protected]0a8db0d2011-04-13 15:15:40379}
380
[email protected]4c219e22012-05-05 19:41:04381// static
382void ChromeNetworkDelegate::AllowAccessToAllFiles() {
383 g_allow_file_access_ = true;
384}
385
[email protected]7a299a92012-10-24 23:54:50386// static
387Value* ChromeNetworkDelegate::HistoricNetworkStatsInfoToValue() {
388 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
389 PrefService* prefs = g_browser_process->local_state();
390 int64 total_received = prefs->GetInt64(prefs::kHttpReceivedContentLength);
391 int64 total_original = prefs->GetInt64(prefs::kHttpOriginalContentLength);
392
393 DictionaryValue* dict = new DictionaryValue();
[email protected]ae638fbe22012-12-07 02:57:42394 // Use strings to avoid overflow. base::Value only supports 32-bit integers.
395 dict->SetString("historic_received_content_length",
396 base::Int64ToString(total_received));
397 dict->SetString("historic_original_content_length",
398 base::Int64ToString(total_original));
[email protected]7a299a92012-10-24 23:54:50399 return dict;
400}
401
402Value* ChromeNetworkDelegate::SessionNetworkStatsInfoToValue() const {
403 DictionaryValue* dict = new DictionaryValue();
[email protected]ae638fbe22012-12-07 02:57:42404 // Use strings to avoid overflow. base::Value only supports 32-bit integers.
405 dict->SetString("session_received_content_length",
406 base::Int64ToString(received_content_length_));
407 dict->SetString("session_original_content_length",
408 base::Int64ToString(original_content_length_));
[email protected]7a299a92012-10-24 23:54:50409 return dict;
410}
411
[email protected]4875ba12011-03-30 22:31:51412int ChromeNetworkDelegate::OnBeforeURLRequest(
[email protected]4c76d7c2011-04-15 19:14:12413 net::URLRequest* request,
[email protected]084262c2011-12-01 21:12:47414 const net::CompletionCallback& callback,
[email protected]4c76d7c2011-04-15 19:14:12415 GURL* new_url) {
[email protected]3e598ff12011-09-06 11:22:34416#if defined(ENABLE_CONFIGURATION_POLICY)
[email protected]6a5f77c32011-09-04 19:19:59417 // TODO(joaodasilva): This prevents extensions from seeing URLs that are
418 // blocked. However, an extension might redirect the request to another URL,
419 // which is not blocked.
420 if (url_blacklist_manager_ &&
[email protected]74575252013-03-12 19:58:21421 url_blacklist_manager_->IsRequestBlocked(*request)) {
[email protected]6a5f77c32011-09-04 19:19:59422 // URL access blocked by policy.
[email protected]6a5f77c32011-09-04 19:19:59423 request->net_log().AddEvent(
[email protected]2fa08912012-06-14 20:56:26424 net::NetLog::TYPE_CHROME_POLICY_ABORTED_REQUEST,
425 net::NetLog::StringCallback("url",
426 &request->url().possibly_invalid_spec()));
[email protected]91468a92013-03-06 17:21:55427 return net::ERR_BLOCKED_BY_ADMINISTRATOR;
[email protected]6a5f77c32011-09-04 19:19:59428 }
[email protected]3e598ff12011-09-06 11:22:34429#endif
[email protected]6a5f77c32011-09-04 19:19:59430
[email protected]6baff0b52012-03-06 01:30:18431 ForwardRequestStatus(REQUEST_STARTED, request, profile_);
432
[email protected]0a8db0d2011-04-13 15:15:40433 if (!enable_referrers_->GetValue())
[email protected]99ecf6e2013-04-10 22:46:13434 request->SetReferrer(std::string());
[email protected]9d8cfb682012-09-13 16:48:04435 if (enable_do_not_track_ && enable_do_not_track_->GetValue())
436 request->SetExtraRequestHeaderByName(kDNTHeader, "1", true /* override */);
[email protected]d1208ba32012-11-08 11:10:33437
[email protected]3620bbc2013-10-05 05:07:23438 if (client_hints_) {
439 request->SetExtraRequestHeaderByName(
440 ClientHints::kDevicePixelRatioHeader,
441 client_hints_->GetDevicePixelRatioHeader(), true);
442 }
443
[email protected]d1208ba32012-11-08 11:10:33444 bool force_safe_search = force_google_safe_search_ &&
445 force_google_safe_search_->GetValue();
446
447 net::CompletionCallback wrapped_callback = callback;
448 if (force_safe_search) {
449 wrapped_callback = base::Bind(&ForceGoogleSafeSearchCallbackWrapper,
450 callback,
451 base::Unretained(request),
452 base::Unretained(new_url));
453 }
454
455 int rv = ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRequest(
456 profile_, extension_info_map_.get(), request, wrapped_callback,
457 new_url);
458
459 if (force_safe_search && rv == net::OK && new_url->is_empty())
460 ForceGoogleSafeSearch(request, new_url);
461
[email protected]f53b4802012-12-20 17:04:23462 if (connect_interceptor_)
463 connect_interceptor_->WitnessURLRequest(request);
464
[email protected]d1208ba32012-11-08 11:10:33465 return rv;
[email protected]d05ef99c2011-02-01 21:38:16466}
467
[email protected]4875ba12011-03-30 22:31:51468int ChromeNetworkDelegate::OnBeforeSendHeaders(
[email protected]636eccd2011-06-28 12:28:01469 net::URLRequest* request,
[email protected]084262c2011-12-01 21:12:47470 const net::CompletionCallback& callback,
[email protected]4c76d7c2011-04-15 19:14:12471 net::HttpRequestHeaders* headers) {
[email protected]186468f2013-10-24 02:44:11472 TRACE_EVENT_ASYNC_STEP_PAST0("net", "URLRequest", request, "SendRequest");
[email protected]4875ba12011-03-30 22:31:51473 return ExtensionWebRequestEventRouter::GetInstance()->OnBeforeSendHeaders(
[email protected]673514522011-07-13 18:17:18474 profile_, extension_info_map_.get(), request, callback, headers);
[email protected]ac039522010-06-15 16:39:44475}
[email protected]8202d0c2011-02-23 08:31:14476
[email protected]5796dc942011-07-14 19:26:10477void ChromeNetworkDelegate::OnSendHeaders(
478 net::URLRequest* request,
[email protected]783573b2011-05-13 11:05:15479 const net::HttpRequestHeaders& headers) {
[email protected]5796dc942011-07-14 19:26:10480 ExtensionWebRequestEventRouter::GetInstance()->OnSendHeaders(
481 profile_, extension_info_map_.get(), request, headers);
[email protected]82b42302011-04-20 16:28:16482}
483
[email protected]ea8141e2011-10-05 13:12:51484int ChromeNetworkDelegate::OnHeadersReceived(
485 net::URLRequest* request,
[email protected]084262c2011-12-01 21:12:47486 const net::CompletionCallback& callback,
[email protected]507af8f2012-10-20 00:42:32487 const net::HttpResponseHeaders* original_response_headers,
[email protected]ea8141e2011-10-05 13:12:51488 scoped_refptr<net::HttpResponseHeaders>* override_response_headers) {
489 return ExtensionWebRequestEventRouter::GetInstance()->OnHeadersReceived(
490 profile_, extension_info_map_.get(), request, callback,
491 original_response_headers, override_response_headers);
492}
493
[email protected]31b2e5f2011-04-20 16:58:32494void ChromeNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
495 const GURL& new_location) {
496 ExtensionWebRequestEventRouter::GetInstance()->OnBeforeRedirect(
[email protected]673514522011-07-13 18:17:18497 profile_, extension_info_map_.get(), request, new_location);
[email protected]31b2e5f2011-04-20 16:58:32498}
499
500
[email protected]8202d0c2011-02-23 08:31:14501void ChromeNetworkDelegate::OnResponseStarted(net::URLRequest* request) {
[email protected]186468f2013-10-24 02:44:11502 TRACE_EVENT_ASYNC_STEP_PAST0("net", "URLRequest", request, "ResponseStarted");
[email protected]62fecae2011-04-21 11:08:24503 ExtensionWebRequestEventRouter::GetInstance()->OnResponseStarted(
[email protected]673514522011-07-13 18:17:18504 profile_, extension_info_map_.get(), request);
505 ForwardProxyErrors(request, event_router_.get(), profile_);
[email protected]8202d0c2011-02-23 08:31:14506}
507
[email protected]8523ba52011-05-22 19:00:58508void ChromeNetworkDelegate::OnRawBytesRead(const net::URLRequest& request,
509 int bytes_read) {
[email protected]186468f2013-10-24 02:44:11510 TRACE_EVENT_ASYNC_STEP_PAST1("net", "URLRequest", &request, "DidRead",
511 "bytes_read", bytes_read);
[email protected]6f4b4b42012-08-27 21:59:07512 performance_monitor::PerformanceMonitor::GetInstance()->BytesReadOnIOThread(
513 request, bytes_read);
514
[email protected]44879ed2012-04-06 01:11:02515#if defined(ENABLE_TASK_MANAGER)
[email protected]8523ba52011-05-22 19:00:58516 TaskManager::GetInstance()->model()->NotifyBytesRead(request, bytes_read);
[email protected]44879ed2012-04-06 01:11:02517#endif // defined(ENABLE_TASK_MANAGER)
[email protected]8523ba52011-05-22 19:00:58518}
519
[email protected]9045b8822012-01-13 20:35:35520void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request,
521 bool started) {
[email protected]4aca5db2013-08-17 00:51:56522 TRACE_EVENT_ASYNC_END0("net", "URLRequest", request);
[email protected]2756a8e2012-09-07 18:24:29523 if (request->status().status() == net::URLRequestStatus::SUCCESS) {
[email protected]7a299a92012-10-24 23:54:50524 // For better accuracy, we use the actual bytes read instead of the length
525 // specified with the Content-Length header, which may be inaccurate,
526 // or missing, as is the case with chunked encoding.
527 int64 received_content_length = request->received_response_content_length();
528
529 // Only record for http or https urls.
530 bool is_http = request->url().SchemeIs("http");
531 bool is_https = request->url().SchemeIs("https");
532
533 if (!request->was_cached() && // Don't record cached content
534 received_content_length && // Zero-byte responses aren't useful.
535 (is_http || is_https)) { // Only record for HTTP or HTTPS urls.
536 int64 original_content_length =
537 request->response_info().headers->GetInt64HeaderValue(
538 "x-original-content-length");
[email protected]828eab22013-12-10 22:42:38539 chrome_browser_net::DataReductionRequestType data_reduction_type =
[email protected]b7796462013-12-12 19:42:34540 chrome_browser_net::GetDataReductionRequestType(request);
[email protected]2db93e42013-08-07 17:40:41541
[email protected]f81a5ee2013-06-20 21:08:49542 base::TimeDelta freshness_lifetime =
543 request->response_info().headers->GetFreshnessLifetime(
544 request->response_info().response_time);
[email protected]828eab22013-12-10 22:42:38545 int64 adjusted_original_content_length =
546 chrome_browser_net::GetAdjustedOriginalContentLength(
547 data_reduction_type, original_content_length,
548 received_content_length);
[email protected]7a299a92012-10-24 23:54:50549 AccumulateContentLength(received_content_length,
[email protected]2db93e42013-08-07 17:40:41550 adjusted_original_content_length,
[email protected]b7796462013-12-12 19:42:34551 data_reduction_type,
552 profile_);
[email protected]7a299a92012-10-24 23:54:50553 RecordContentLengthHistograms(received_content_length,
[email protected]f81a5ee2013-06-20 21:08:49554 original_content_length,
555 freshness_lifetime);
[email protected]7a299a92012-10-24 23:54:50556 DVLOG(2) << __FUNCTION__
557 << " received content length: " << received_content_length
558 << " original content length: " << original_content_length
559 << " url: " << request->url();
560 }
561
[email protected]48944382011-04-23 13:28:16562 bool is_redirect = request->response_headers() &&
563 net::HttpResponseHeaders::IsRedirectResponseCode(
564 request->response_headers()->response_code());
565 if (!is_redirect) {
566 ExtensionWebRequestEventRouter::GetInstance()->OnCompleted(
[email protected]673514522011-07-13 18:17:18567 profile_, extension_info_map_.get(), request);
[email protected]48944382011-04-23 13:28:16568 }
[email protected]a83dd332011-07-13 10:41:01569 } else if (request->status().status() == net::URLRequestStatus::FAILED ||
570 request->status().status() == net::URLRequestStatus::CANCELED) {
[email protected]05b6ab42011-04-23 13:46:04571 ExtensionWebRequestEventRouter::GetInstance()->OnErrorOccurred(
[email protected]9045b8822012-01-13 20:35:35572 profile_, extension_info_map_.get(), request, started);
[email protected]a83dd332011-07-13 10:41:01573 } else {
574 NOTREACHED();
[email protected]48944382011-04-23 13:28:16575 }
[email protected]673514522011-07-13 18:17:18576 ForwardProxyErrors(request, event_router_.get(), profile_);
[email protected]6baff0b52012-03-06 01:30:18577
578 ForwardRequestStatus(REQUEST_DONE, request, profile_);
[email protected]8202d0c2011-02-23 08:31:14579}
[email protected]4b50cb52011-03-10 00:29:37580
[email protected]4875ba12011-03-30 22:31:51581void ChromeNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) {
582 ExtensionWebRequestEventRouter::GetInstance()->OnURLRequestDestroyed(
[email protected]673514522011-07-13 18:17:18583 profile_, request);
[email protected]16d5c72b2012-09-14 20:42:37584 if (load_time_stats_)
585 load_time_stats_->OnURLRequestDestroyed(*request);
[email protected]4875ba12011-03-30 22:31:51586}
587
[email protected]82a37672011-05-03 12:02:41588void ChromeNetworkDelegate::OnPACScriptError(int line_number,
[email protected]439f1e32013-12-09 20:09:09589 const base::string16& error) {
[email protected]c454fe672012-03-12 21:18:01590 extensions::ProxyEventRouter::GetInstance()->OnPACScriptError(
[email protected]673514522011-07-13 18:17:18591 event_router_.get(), profile_, line_number, error);
[email protected]82a37672011-05-03 12:02:41592}
[email protected]7efc582d2011-08-03 20:46:35593
[email protected]c2911d72011-10-03 22:16:36594net::NetworkDelegate::AuthRequiredResponse
595ChromeNetworkDelegate::OnAuthRequired(
[email protected]7efc582d2011-08-03 20:46:35596 net::URLRequest* request,
[email protected]c2911d72011-10-03 22:16:36597 const net::AuthChallengeInfo& auth_info,
598 const AuthCallback& callback,
599 net::AuthCredentials* credentials) {
[email protected]90449ab2011-10-11 15:36:45600 return ExtensionWebRequestEventRouter::GetInstance()->OnAuthRequired(
601 profile_, extension_info_map_.get(), request, auth_info,
602 callback, credentials);
[email protected]7efc582d2011-08-03 20:46:35603}
[email protected]9c8ae8c2012-03-09 13:13:35604
[email protected]4c219e22012-05-05 19:41:04605bool ChromeNetworkDelegate::OnCanGetCookies(
606 const net::URLRequest& request,
[email protected]9c8ae8c2012-03-09 13:13:35607 const net::CookieList& cookie_list) {
608 // NULL during tests, or when we're running in the system context.
[email protected]5173de8b2013-06-02 21:16:02609 if (!cookie_settings_.get())
[email protected]9c8ae8c2012-03-09 13:13:35610 return true;
611
612 bool allow = cookie_settings_->IsReadingCookieAllowed(
[email protected]4c219e22012-05-05 19:41:04613 request.url(), request.first_party_for_cookies());
[email protected]9c8ae8c2012-03-09 13:13:35614
615 int render_process_id = -1;
616 int render_view_id = -1;
617 if (content::ResourceRequestInfo::GetRenderViewForRequest(
[email protected]4c219e22012-05-05 19:41:04618 &request, &render_process_id, &render_view_id)) {
[email protected]9c8ae8c2012-03-09 13:13:35619 BrowserThread::PostTask(
620 BrowserThread::UI, FROM_HERE,
621 base::Bind(&TabSpecificContentSettings::CookiesRead,
622 render_process_id, render_view_id,
[email protected]4c219e22012-05-05 19:41:04623 request.url(), request.first_party_for_cookies(),
[email protected]fd473d12012-04-05 11:38:43624 cookie_list, !allow));
[email protected]9c8ae8c2012-03-09 13:13:35625 }
626
627 return allow;
628}
629
[email protected]4c219e22012-05-05 19:41:04630bool ChromeNetworkDelegate::OnCanSetCookie(const net::URLRequest& request,
631 const std::string& cookie_line,
632 net::CookieOptions* options) {
[email protected]9c8ae8c2012-03-09 13:13:35633 // NULL during tests, or when we're running in the system context.
[email protected]5173de8b2013-06-02 21:16:02634 if (!cookie_settings_.get())
[email protected]9c8ae8c2012-03-09 13:13:35635 return true;
636
637 bool allow = cookie_settings_->IsSettingCookieAllowed(
[email protected]4c219e22012-05-05 19:41:04638 request.url(), request.first_party_for_cookies());
[email protected]9c8ae8c2012-03-09 13:13:35639
[email protected]9c8ae8c2012-03-09 13:13:35640 int render_process_id = -1;
641 int render_view_id = -1;
642 if (content::ResourceRequestInfo::GetRenderViewForRequest(
[email protected]4c219e22012-05-05 19:41:04643 &request, &render_process_id, &render_view_id)) {
[email protected]9c8ae8c2012-03-09 13:13:35644 BrowserThread::PostTask(
645 BrowserThread::UI, FROM_HERE,
646 base::Bind(&TabSpecificContentSettings::CookieChanged,
647 render_process_id, render_view_id,
[email protected]4c219e22012-05-05 19:41:04648 request.url(), request.first_party_for_cookies(),
[email protected]fd473d12012-04-05 11:38:43649 cookie_line, *options, !allow));
[email protected]9c8ae8c2012-03-09 13:13:35650 }
651
652 return allow;
653}
[email protected]4c219e22012-05-05 19:41:04654
655bool ChromeNetworkDelegate::OnCanAccessFile(const net::URLRequest& request,
[email protected]650b2d52013-02-10 03:41:45656 const base::FilePath& path) const {
[email protected]4c219e22012-05-05 19:41:04657 if (g_allow_file_access_)
658 return true;
659
[email protected]d8e4f132012-09-06 04:28:05660#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
661 return true;
662#else
[email protected]4c219e22012-05-05 19:41:04663#if defined(OS_CHROMEOS)
[email protected]d8e4f132012-09-06 04:28:05664 // If we're running Chrome for ChromeOS on Linux, we want to allow file
665 // access.
[email protected]49c4cf852013-09-27 19:28:24666 if (!base::SysInfo::IsRunningOnChromeOS() ||
[email protected]288538482012-09-06 21:09:35667 CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) {
[email protected]d8e4f132012-09-06 04:28:05668 return true;
[email protected]288538482012-09-06 21:09:35669 }
[email protected]d8e4f132012-09-06 04:28:05670
671 // Use a whitelist to only allow access to files residing in the list of
672 // directories below.
[email protected]4c219e22012-05-05 19:41:04673 static const char* const kLocalAccessWhiteList[] = {
674 "/home/chronos/user/Downloads",
675 "/home/chronos/user/log",
676 "/media",
677 "/opt/oem",
678 "/usr/share/chromeos-assets",
679 "/tmp",
680 "/var/log",
681 };
[email protected]ae015e12013-11-04 19:11:33682
683 // The actual location of "/home/chronos/user/Downloads" is the Downloads
684 // directory under the profile path ("/home/chronos/user' is a hard link to
685 // current primary logged in profile.) For the support of multi-profile
686 // sessions, we are switching to use explicit "$PROFILE_PATH/Downloads" path
687 // and here whitelist such access.
688 if (!profile_path_.empty()) {
689 const base::FilePath downloads = profile_path_.AppendASCII("Downloads");
690 if (downloads == path.StripTrailingSeparators() || downloads.IsParent(path))
691 return true;
692 }
[email protected]d8e4f132012-09-06 04:28:05693#elif defined(OS_ANDROID)
694 // Access to files in external storage is allowed.
[email protected]650b2d52013-02-10 03:41:45695 base::FilePath external_storage_path;
[email protected]d8e4f132012-09-06 04:28:05696 PathService::Get(base::DIR_ANDROID_EXTERNAL_STORAGE, &external_storage_path);
697 if (external_storage_path.IsParent(path))
[email protected]4c219e22012-05-05 19:41:04698 return true;
699
[email protected]d8e4f132012-09-06 04:28:05700 // Whitelist of other allowed directories.
701 static const char* const kLocalAccessWhiteList[] = {
702 "/sdcard",
703 "/mnt/sdcard",
704 };
705#endif
706
[email protected]4c219e22012-05-05 19:41:04707 for (size_t i = 0; i < arraysize(kLocalAccessWhiteList); ++i) {
[email protected]650b2d52013-02-10 03:41:45708 const base::FilePath white_listed_path(kLocalAccessWhiteList[i]);
709 // base::FilePath::operator== should probably handle trailing separators.
[email protected]4c219e22012-05-05 19:41:04710 if (white_listed_path == path.StripTrailingSeparators() ||
711 white_listed_path.IsParent(path)) {
712 return true;
713 }
714 }
[email protected]d8e4f132012-09-06 04:28:05715
[email protected]288538482012-09-06 21:09:35716 DVLOG(1) << "File access denied - " << path.value().c_str();
[email protected]4c219e22012-05-05 19:41:04717 return false;
[email protected]d8e4f132012-09-06 04:28:05718#endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
[email protected]4c219e22012-05-05 19:41:04719}
[email protected]a1d4ab072012-06-07 13:21:15720
721bool ChromeNetworkDelegate::OnCanThrottleRequest(
722 const net::URLRequest& request) const {
[email protected]c4a7df82012-08-09 22:48:46723 if (g_never_throttle_requests_) {
[email protected]a1d4ab072012-06-07 13:21:15724 return false;
725 }
726
[email protected]c4a7df82012-08-09 22:48:46727 return request.first_party_for_cookies().scheme() ==
[email protected]885c0e92012-11-13 20:27:42728 extensions::kExtensionScheme;
[email protected]a1d4ab072012-06-07 13:21:15729}
[email protected]aa28181e2012-06-13 00:53:58730
[email protected]e6d017652013-05-17 18:01:40731bool ChromeNetworkDelegate::OnCanEnablePrivacyMode(
732 const GURL& url,
733 const GURL& first_party_for_cookies) const {
734 // NULL during tests, or when we're running in the system context.
[email protected]5173de8b2013-06-02 21:16:02735 if (!cookie_settings_.get())
[email protected]e6d017652013-05-17 18:01:40736 return false;
737
738 bool reading_cookie_allowed = cookie_settings_->IsReadingCookieAllowed(
739 url, first_party_for_cookies);
740 bool setting_cookie_allowed = cookie_settings_->IsSettingCookieAllowed(
741 url, first_party_for_cookies);
742 bool privacy_mode = !(reading_cookie_allowed && setting_cookie_allowed);
743 return privacy_mode;
744}
745
[email protected]aa28181e2012-06-13 00:53:58746int ChromeNetworkDelegate::OnBeforeSocketStreamConnect(
747 net::SocketStream* socket,
748 const net::CompletionCallback& callback) {
749#if defined(ENABLE_CONFIGURATION_POLICY)
750 if (url_blacklist_manager_ &&
751 url_blacklist_manager_->IsURLBlocked(socket->url())) {
752 // URL access blocked by policy.
[email protected]aa28181e2012-06-13 00:53:58753 socket->net_log()->AddEvent(
[email protected]2fa08912012-06-14 20:56:26754 net::NetLog::TYPE_CHROME_POLICY_ABORTED_REQUEST,
755 net::NetLog::StringCallback("url",
756 &socket->url().possibly_invalid_spec()));
[email protected]91468a92013-03-06 17:21:55757 return net::ERR_BLOCKED_BY_ADMINISTRATOR;
[email protected]aa28181e2012-06-13 00:53:58758 }
759#endif
760 return net::OK;
761}
[email protected]5a07c192012-07-30 20:18:22762
[email protected]a9e0d1412012-08-20 22:13:01763void ChromeNetworkDelegate::OnRequestWaitStateChange(
[email protected]5a07c192012-07-30 20:18:22764 const net::URLRequest& request,
[email protected]a9e0d1412012-08-20 22:13:01765 RequestWaitState state) {
766 if (load_time_stats_)
767 load_time_stats_->OnRequestWaitStateChange(request, state);
[email protected]5a07c192012-07-30 20:18:22768}
[email protected]7a299a92012-10-24 23:54:50769
770void ChromeNetworkDelegate::AccumulateContentLength(
[email protected]b7796462013-12-12 19:42:34771 int64 received_content_length,
772 int64 original_content_length,
773 chrome_browser_net::DataReductionRequestType data_reduction_type,
774 void* profile) {
[email protected]7a299a92012-10-24 23:54:50775 DCHECK_GE(received_content_length, 0);
776 DCHECK_GE(original_content_length, 0);
777 StoreAccumulatedContentLength(received_content_length,
[email protected]2db93e42013-08-07 17:40:41778 original_content_length,
[email protected]b7796462013-12-12 19:42:34779 data_reduction_type,
780 reinterpret_cast<Profile*>(profile_));
[email protected]7a299a92012-10-24 23:54:50781 received_content_length_ += received_content_length;
782 original_content_length_ += original_content_length;
783}