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

Side by Side Diff: chrome/browser/profiles/profile_io_data.cc

Issue 182993003: Add the ability for DevTools to wrap network transactions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/profiles/profile_io_data.h" 5 #include "chrome/browser/profiles/profile_io_data.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 10 matching lines...) Expand all
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
23 #include "base/threading/sequenced_worker_pool.h" 23 #include "base/threading/sequenced_worker_pool.h"
24 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
25 #include "chrome/browser/chrome_notification_types.h" 25 #include "chrome/browser/chrome_notification_types.h"
26 #include "chrome/browser/content_settings/content_settings_provider.h" 26 #include "chrome/browser/content_settings/content_settings_provider.h"
27 #include "chrome/browser/content_settings/cookie_settings.h" 27 #include "chrome/browser/content_settings/cookie_settings.h"
28 #include "chrome/browser/content_settings/host_content_settings_map.h" 28 #include "chrome/browser/content_settings/host_content_settings_map.h"
29 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 29 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
30 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" 30 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
31 #include "chrome/browser/devtools/devtools_network_controller.h"
32 #include "chrome/browser/devtools/devtools_network_transaction_factory.h"
31 #include "chrome/browser/download/download_service.h" 33 #include "chrome/browser/download/download_service.h"
32 #include "chrome/browser/download/download_service_factory.h" 34 #include "chrome/browser/download/download_service_factory.h"
33 #include "chrome/browser/extensions/extension_resource_protocols.h" 35 #include "chrome/browser/extensions/extension_resource_protocols.h"
34 #include "chrome/browser/io_thread.h" 36 #include "chrome/browser/io_thread.h"
35 #include "chrome/browser/media/media_device_id_salt.h" 37 #include "chrome/browser/media/media_device_id_salt.h"
36 #include "chrome/browser/net/about_protocol_handler.h" 38 #include "chrome/browser/net/about_protocol_handler.h"
37 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" 39 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h"
38 #include "chrome/browser/net/chrome_http_user_agent_settings.h" 40 #include "chrome/browser/net/chrome_http_user_agent_settings.h"
39 #include "chrome/browser/net/chrome_net_log.h" 41 #include "chrome/browser/net/chrome_net_log.h"
40 #include "chrome/browser/net/chrome_network_delegate.h" 42 #include "chrome/browser/net/chrome_network_delegate.h"
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 738
737 HostContentSettingsMap* ProfileIOData::GetHostContentSettingsMap() const { 739 HostContentSettingsMap* ProfileIOData::GetHostContentSettingsMap() const {
738 DCHECK(initialized_); 740 DCHECK(initialized_);
739 return host_content_settings_map_.get(); 741 return host_content_settings_map_.get();
740 } 742 }
741 743
742 ResourceContext::SaltCallback ProfileIOData::GetMediaDeviceIDSalt() const { 744 ResourceContext::SaltCallback ProfileIOData::GetMediaDeviceIDSalt() const {
743 return base::Bind(&MediaDeviceIDSalt::GetSalt, media_device_id_salt_); 745 return base::Bind(&MediaDeviceIDSalt::GetSalt, media_device_id_salt_);
744 } 746 }
745 747
748 void ProfileIOData::SetNetworkState(
749 const std::string& client_id, bool offline) const {
750 DCHECK(network_controller_);
751 network_controller_->SetNetworkState(client_id, offline);
752 }
753
746 bool ProfileIOData::IsOffTheRecord() const { 754 bool ProfileIOData::IsOffTheRecord() const {
747 return profile_type() == Profile::INCOGNITO_PROFILE 755 return profile_type() == Profile::INCOGNITO_PROFILE
748 || profile_type() == Profile::GUEST_PROFILE; 756 || profile_type() == Profile::GUEST_PROFILE;
749 } 757 }
750 758
751 void ProfileIOData::InitializeMetricsEnabledStateOnUIThread() { 759 void ProfileIOData::InitializeMetricsEnabledStateOnUIThread() {
752 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 760 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
753 #if defined(OS_CHROMEOS) 761 #if defined(OS_CHROMEOS)
754 // Just fetch the value from ChromeOS' settings while we're on the UI thread. 762 // Just fetch the value from ChromeOS' settings while we're on the UI thread.
755 // TODO(stevet): For now, this value is only set on profile initialization. 763 // TODO(stevet): For now, this value is only set on profile initialization.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 ContentSetting setting = content_settings->GetContentSetting( 896 ContentSetting setting = content_settings->GetContentSetting(
889 origin, origin, type, NO_RESOURCE_IDENTIFIER); 897 origin, origin, type, NO_RESOURCE_IDENTIFIER);
890 return setting == CONTENT_SETTING_ALLOW; 898 return setting == CONTENT_SETTING_ALLOW;
891 } 899 }
892 900
893 ResourceContext::SaltCallback 901 ResourceContext::SaltCallback
894 ProfileIOData::ResourceContext::GetMediaDeviceIDSalt() { 902 ProfileIOData::ResourceContext::GetMediaDeviceIDSalt() {
895 return io_data_->GetMediaDeviceIDSalt(); 903 return io_data_->GetMediaDeviceIDSalt();
896 } 904 }
897 905
906 void ProfileIOData::ResourceContext::SetNetworkState(
907 const std::string& client_id,
908 bool offline) {
909 io_data_->SetNetworkState(client_id, offline);
910 }
911
898 // static 912 // static
899 std::string ProfileIOData::GetSSLSessionCacheShard() { 913 std::string ProfileIOData::GetSSLSessionCacheShard() {
900 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 914 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
901 // The SSL session cache is partitioned by setting a string. This returns a 915 // The SSL session cache is partitioned by setting a string. This returns a
902 // unique string to partition the SSL session cache. Each time we create a 916 // unique string to partition the SSL session cache. Each time we create a
903 // new profile, we'll get a fresh SSL session cache which is separate from 917 // new profile, we'll get a fresh SSL session cache which is separate from
904 // the other profiles. 918 // the other profiles.
905 static unsigned ssl_session_cache_instance = 0; 919 static unsigned ssl_session_cache_instance = 0;
906 return base::StringPrintf("profile/%u", ssl_session_cache_instance++); 920 return base::StringPrintf("profile/%u", ssl_session_cache_instance++);
907 } 921 }
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 1151
1138 void ProfileIOData::set_server_bound_cert_service( 1152 void ProfileIOData::set_server_bound_cert_service(
1139 net::ServerBoundCertService* server_bound_cert_service) const { 1153 net::ServerBoundCertService* server_bound_cert_service) const {
1140 server_bound_cert_service_.reset(server_bound_cert_service); 1154 server_bound_cert_service_.reset(server_bound_cert_service);
1141 } 1155 }
1142 1156
1143 void ProfileIOData::DestroyResourceContext() { 1157 void ProfileIOData::DestroyResourceContext() {
1144 resource_context_.reset(); 1158 resource_context_.reset();
1145 } 1159 }
1146 1160
1147 void ProfileIOData::PopulateNetworkSessionParams( 1161 scoped_ptr<net::HttpCache> ProfileIOData::CreateMainHttpFactory(
1148 const ProfileParams* profile_params, 1162 const ProfileParams* profile_params,
1149 net::HttpNetworkSession::Params* params) const { 1163 net::HttpCache::BackendFactory* main_backend) const {
1150 1164 net::HttpNetworkSession::Params params;
1151 ChromeURLRequestContext* context = main_request_context(); 1165 ChromeURLRequestContext* context = main_request_context();
1152 1166
1153 IOThread* const io_thread = profile_params->io_thread; 1167 IOThread* const io_thread = profile_params->io_thread;
1154 1168
1155 io_thread->InitializeNetworkSessionParams(params); 1169 io_thread->InitializeNetworkSessionParams(&params);
1156 1170
1157 params->host_resolver = context->host_resolver(); 1171 params.host_resolver = context->host_resolver();
1158 params->cert_verifier = context->cert_verifier(); 1172 params.cert_verifier = context->cert_verifier();
1159 params->server_bound_cert_service = context->server_bound_cert_service(); 1173 params.server_bound_cert_service = context->server_bound_cert_service();
1160 params->transport_security_state = context->transport_security_state(); 1174 params.transport_security_state = context->transport_security_state();
1161 params->cert_transparency_verifier = context->cert_transparency_verifier(); 1175 params.cert_transparency_verifier = context->cert_transparency_verifier();
1162 params->proxy_service = context->proxy_service(); 1176 params.proxy_service = context->proxy_service();
1163 params->ssl_session_cache_shard = GetSSLSessionCacheShard(); 1177 params.ssl_session_cache_shard = GetSSLSessionCacheShard();
1164 params->ssl_config_service = context->ssl_config_service(); 1178 params.ssl_config_service = context->ssl_config_service();
1165 params->http_auth_handler_factory = context->http_auth_handler_factory(); 1179 params.http_auth_handler_factory = context->http_auth_handler_factory();
1166 params->network_delegate = network_delegate(); 1180 params.network_delegate = network_delegate();
1167 params->http_server_properties = context->http_server_properties(); 1181 params.http_server_properties = context->http_server_properties();
1168 params->net_log = context->net_log(); 1182 params.net_log = context->net_log();
1183
1184 network_controller_.reset(new DevToolsNetworkController());
1185
1186 net::HttpNetworkSession* session = new net::HttpNetworkSession(params);
1187 return scoped_ptr<net::HttpCache>(new net::HttpCache(
1188 new DevToolsNetworkTransactionFactory(network_controller_.get(), session),
1189 context->net_log(), main_backend));
1190 }
1191
1192 scoped_ptr<net::HttpCache> ProfileIOData::CreateHttpFactory(
1193 net::HttpNetworkSession* shared_session,
1194 net::HttpCache::BackendFactory* backend) const {
1195 return scoped_ptr<net::HttpCache>(new net::HttpCache(
1196 new DevToolsNetworkTransactionFactory(
1197 network_controller_.get(), shared_session),
1198 shared_session->net_log(), backend));
1169 } 1199 }
1170 1200
1171 void ProfileIOData::SetCookieSettingsForTesting( 1201 void ProfileIOData::SetCookieSettingsForTesting(
1172 CookieSettings* cookie_settings) { 1202 CookieSettings* cookie_settings) {
1173 DCHECK(!cookie_settings_.get()); 1203 DCHECK(!cookie_settings_.get());
1174 cookie_settings_ = cookie_settings; 1204 cookie_settings_ = cookie_settings;
1175 } 1205 }
1176 1206
1177 void ProfileIOData::set_signin_names_for_testing( 1207 void ProfileIOData::set_signin_names_for_testing(
1178 SigninNamesOnIOThread* signin_names) { 1208 SigninNamesOnIOThread* signin_names) {
1179 signin_names_.reset(signin_names); 1209 signin_names_.reset(signin_names);
1180 } 1210 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_io_data.h ('k') | chrome/chrome.gyp » ('j') | net/net.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698