| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/net/chrome_network_delegate.h" | 5 #include "chrome/browser/net/chrome_network_delegate.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/base_paths.h" | 11 #include "base/base_paths.h" |
| 12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/prefs/pref_member.h" | 16 #include "base/prefs/pref_member.h" |
| 17 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/string_split.h" | 19 #include "base/strings/string_split.h" |
| 20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/content_settings/cookie_settings.h" | 22 #include "chrome/browser/content_settings/cookie_settings.h" |
| 23 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 23 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 24 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 24 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 25 #include "chrome/browser/extensions/api/proxy/proxy_api.h" | 25 #include "chrome/browser/extensions/api/proxy/proxy_api.h" |
| 26 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 26 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
| 27 #include "chrome/browser/extensions/event_router_forwarder.h" | 27 #include "chrome/browser/extensions/event_router_forwarder.h" |
| 28 #include "chrome/browser/extensions/extension_process_manager.h" | |
| 29 #include "chrome/browser/extensions/extension_system.h" | 28 #include "chrome/browser/extensions/extension_system.h" |
| 30 #include "chrome/browser/google/google_util.h" | 29 #include "chrome/browser/google/google_util.h" |
| 31 #include "chrome/browser/net/chrome_network_data_saving_metrics.h" | 30 #include "chrome/browser/net/chrome_network_data_saving_metrics.h" |
| 32 #include "chrome/browser/net/client_hints.h" | 31 #include "chrome/browser/net/client_hints.h" |
| 33 #include "chrome/browser/net/connect_interceptor.h" | 32 #include "chrome/browser/net/connect_interceptor.h" |
| 34 #include "chrome/browser/net/load_time_stats.h" | 33 #include "chrome/browser/net/load_time_stats.h" |
| 35 #include "chrome/browser/performance_monitor/performance_monitor.h" | 34 #include "chrome/browser/performance_monitor/performance_monitor.h" |
| 36 #include "chrome/browser/profiles/profile_manager.h" | 35 #include "chrome/browser/profiles/profile_manager.h" |
| 37 #include "chrome/browser/task_manager/task_manager.h" | 36 #include "chrome/browser/task_manager/task_manager.h" |
| 38 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
| 39 #include "chrome/common/url_constants.h" | 38 #include "chrome/common/url_constants.h" |
| 40 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
| 41 #include "content/public/browser/render_view_host.h" | 40 #include "content/public/browser/render_view_host.h" |
| 42 #include "content/public/browser/resource_request_info.h" | 41 #include "content/public/browser/resource_request_info.h" |
| 43 #include "extensions/browser/info_map.h" | 42 #include "extensions/browser/info_map.h" |
| 43 #include "extensions/browser/process_manager.h" |
| 44 #include "extensions/common/constants.h" | 44 #include "extensions/common/constants.h" |
| 45 #include "net/base/host_port_pair.h" | 45 #include "net/base/host_port_pair.h" |
| 46 #include "net/base/net_errors.h" | 46 #include "net/base/net_errors.h" |
| 47 #include "net/base/net_log.h" | 47 #include "net/base/net_log.h" |
| 48 #include "net/cookies/canonical_cookie.h" | 48 #include "net/cookies/canonical_cookie.h" |
| 49 #include "net/cookies/cookie_options.h" | 49 #include "net/cookies/cookie_options.h" |
| 50 #include "net/http/http_request_headers.h" | 50 #include "net/http/http_request_headers.h" |
| 51 #include "net/http/http_response_headers.h" | 51 #include "net/http/http_response_headers.h" |
| 52 #include "net/socket_stream/socket_stream.h" | 52 #include "net/socket_stream/socket_stream.h" |
| 53 #include "net/url_request/url_request.h" | 53 #include "net/url_request/url_request.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 net::URLRequest* request, | 162 net::URLRequest* request, |
| 163 GURL* new_url, | 163 GURL* new_url, |
| 164 int rv) { | 164 int rv) { |
| 165 if (rv == net::OK && new_url->is_empty()) | 165 if (rv == net::OK && new_url->is_empty()) |
| 166 ForceGoogleSafeSearch(request, new_url); | 166 ForceGoogleSafeSearch(request, new_url); |
| 167 callback.Run(rv); | 167 callback.Run(rv); |
| 168 } | 168 } |
| 169 | 169 |
| 170 enum RequestStatus { REQUEST_STARTED, REQUEST_DONE }; | 170 enum RequestStatus { REQUEST_STARTED, REQUEST_DONE }; |
| 171 | 171 |
| 172 // Notifies the ExtensionProcessManager that a request has started or stopped | 172 // Notifies the extensions::ProcessManager that a request has started or stopped |
| 173 // for a particular RenderView. | 173 // for a particular RenderView. |
| 174 void NotifyEPMRequestStatus(RequestStatus status, | 174 void NotifyEPMRequestStatus(RequestStatus status, |
| 175 void* profile_id, | 175 void* profile_id, |
| 176 int process_id, | 176 int process_id, |
| 177 int render_view_id) { | 177 int render_view_id) { |
| 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 179 Profile* profile = reinterpret_cast<Profile*>(profile_id); | 179 Profile* profile = reinterpret_cast<Profile*>(profile_id); |
| 180 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) | 180 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) |
| 181 return; | 181 return; |
| 182 | 182 |
| 183 ExtensionProcessManager* extension_process_manager = | 183 extensions::ProcessManager* process_manager = |
| 184 extensions::ExtensionSystem::Get(profile)->process_manager(); | 184 extensions::ExtensionSystem::Get(profile)->process_manager(); |
| 185 // This may be NULL in unit tests. | 185 // This may be NULL in unit tests. |
| 186 if (!extension_process_manager) | 186 if (!process_manager) |
| 187 return; | 187 return; |
| 188 | 188 |
| 189 // Will be NULL if the request was not issued on behalf of a renderer (e.g. a | 189 // Will be NULL if the request was not issued on behalf of a renderer (e.g. a |
| 190 // system-level request). | 190 // system-level request). |
| 191 RenderViewHost* render_view_host = | 191 RenderViewHost* render_view_host = |
| 192 RenderViewHost::FromID(process_id, render_view_id); | 192 RenderViewHost::FromID(process_id, render_view_id); |
| 193 if (render_view_host) { | 193 if (render_view_host) { |
| 194 if (status == REQUEST_STARTED) { | 194 if (status == REQUEST_STARTED) { |
| 195 extension_process_manager->OnNetworkRequestStarted(render_view_host); | 195 process_manager->OnNetworkRequestStarted(render_view_host); |
| 196 } else if (status == REQUEST_DONE) { | 196 } else if (status == REQUEST_DONE) { |
| 197 extension_process_manager->OnNetworkRequestDone(render_view_host); | 197 process_manager->OnNetworkRequestDone(render_view_host); |
| 198 } else { | 198 } else { |
| 199 NOTREACHED(); | 199 NOTREACHED(); |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 | 203 |
| 204 void ForwardRequestStatus( | 204 void ForwardRequestStatus( |
| 205 RequestStatus status, net::URLRequest* request, void* profile_id) { | 205 RequestStatus status, net::URLRequest* request, void* profile_id) { |
| 206 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 206 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| 207 if (!info) | 207 if (!info) |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 int64 received_content_length, int64 original_content_length, | 761 int64 received_content_length, int64 original_content_length, |
| 762 bool via_data_reduction_proxy) { | 762 bool via_data_reduction_proxy) { |
| 763 DCHECK_GE(received_content_length, 0); | 763 DCHECK_GE(received_content_length, 0); |
| 764 DCHECK_GE(original_content_length, 0); | 764 DCHECK_GE(original_content_length, 0); |
| 765 StoreAccumulatedContentLength(received_content_length, | 765 StoreAccumulatedContentLength(received_content_length, |
| 766 original_content_length, | 766 original_content_length, |
| 767 via_data_reduction_proxy); | 767 via_data_reduction_proxy); |
| 768 received_content_length_ += received_content_length; | 768 received_content_length_ += received_content_length; |
| 769 original_content_length_ += original_content_length; | 769 original_content_length_ += original_content_length; |
| 770 } | 770 } |
| OLD | NEW |