| 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_url_request_context.h" | 5 #include "chrome/browser/net/chrome_url_request_context.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 virtual ChromeURLRequestContext* Create() OVERRIDE { | 50 virtual ChromeURLRequestContext* Create() OVERRIDE { |
| 51 profile_io_data_->Init(&protocol_handlers_); | 51 profile_io_data_->Init(&protocol_handlers_); |
| 52 return profile_io_data_->GetMainRequestContext(); | 52 return profile_io_data_->GetMainRequestContext(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 const ProfileIOData* const profile_io_data_; | 56 const ProfileIOData* const profile_io_data_; |
| 57 content::ProtocolHandlerMap protocol_handlers_; | 57 content::ProtocolHandlerMap protocol_handlers_; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 // Factory that creates the ChromeURLRequestContext for extensions. | |
| 61 class FactoryForExtensions : public ChromeURLRequestContextFactory { | |
| 62 public: | |
| 63 explicit FactoryForExtensions(const ProfileIOData* profile_io_data) | |
| 64 : profile_io_data_(profile_io_data) {} | |
| 65 | |
| 66 virtual ChromeURLRequestContext* Create() OVERRIDE { | |
| 67 return profile_io_data_->GetExtensionsRequestContext(); | |
| 68 } | |
| 69 | |
| 70 private: | |
| 71 const ProfileIOData* const profile_io_data_; | |
| 72 }; | |
| 73 | |
| 74 // Factory that creates the ChromeURLRequestContext for a given isolated app. | 60 // Factory that creates the ChromeURLRequestContext for a given isolated app. |
| 75 class FactoryForIsolatedApp : public ChromeURLRequestContextFactory { | 61 class FactoryForIsolatedApp : public ChromeURLRequestContextFactory { |
| 76 public: | 62 public: |
| 77 FactoryForIsolatedApp( | 63 FactoryForIsolatedApp( |
| 78 const ProfileIOData* profile_io_data, | 64 const ProfileIOData* profile_io_data, |
| 79 const StoragePartitionDescriptor& partition_descriptor, | 65 const StoragePartitionDescriptor& partition_descriptor, |
| 80 ChromeURLRequestContextGetter* main_context, | 66 ChromeURLRequestContextGetter* main_context, |
| 81 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 67 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 82 protocol_handler_interceptor, | 68 protocol_handler_interceptor, |
| 83 content::ProtocolHandlerMap* protocol_handlers) | 69 content::ProtocolHandlerMap* protocol_handlers) |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 ChromeURLRequestContextGetter* | 192 ChromeURLRequestContextGetter* |
| 207 ChromeURLRequestContextGetter::CreateOriginalForMedia( | 193 ChromeURLRequestContextGetter::CreateOriginalForMedia( |
| 208 Profile* profile, const ProfileIOData* profile_io_data) { | 194 Profile* profile, const ProfileIOData* profile_io_data) { |
| 209 DCHECK(!profile->IsOffTheRecord()); | 195 DCHECK(!profile->IsOffTheRecord()); |
| 210 return new ChromeURLRequestContextGetter( | 196 return new ChromeURLRequestContextGetter( |
| 211 new FactoryForMedia(profile_io_data)); | 197 new FactoryForMedia(profile_io_data)); |
| 212 } | 198 } |
| 213 | 199 |
| 214 // static | 200 // static |
| 215 ChromeURLRequestContextGetter* | 201 ChromeURLRequestContextGetter* |
| 216 ChromeURLRequestContextGetter::CreateOriginalForExtensions( | |
| 217 Profile* profile, const ProfileIOData* profile_io_data) { | |
| 218 DCHECK(!profile->IsOffTheRecord()); | |
| 219 return new ChromeURLRequestContextGetter( | |
| 220 new FactoryForExtensions(profile_io_data)); | |
| 221 } | |
| 222 | |
| 223 // static | |
| 224 ChromeURLRequestContextGetter* | |
| 225 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( | 202 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( |
| 226 Profile* profile, | 203 Profile* profile, |
| 227 const ProfileIOData* profile_io_data, | 204 const ProfileIOData* profile_io_data, |
| 228 const StoragePartitionDescriptor& partition_descriptor, | 205 const StoragePartitionDescriptor& partition_descriptor, |
| 229 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 206 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 230 protocol_handler_interceptor, | 207 protocol_handler_interceptor, |
| 231 content::ProtocolHandlerMap* protocol_handlers) { | 208 content::ProtocolHandlerMap* protocol_handlers) { |
| 232 DCHECK(!profile->IsOffTheRecord()); | 209 DCHECK(!profile->IsOffTheRecord()); |
| 233 ChromeURLRequestContextGetter* main_context = | 210 ChromeURLRequestContextGetter* main_context = |
| 234 static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext()); | 211 static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 258 Profile* profile, | 235 Profile* profile, |
| 259 const ProfileIOData* profile_io_data, | 236 const ProfileIOData* profile_io_data, |
| 260 content::ProtocolHandlerMap* protocol_handlers) { | 237 content::ProtocolHandlerMap* protocol_handlers) { |
| 261 DCHECK(profile->IsOffTheRecord()); | 238 DCHECK(profile->IsOffTheRecord()); |
| 262 return new ChromeURLRequestContextGetter( | 239 return new ChromeURLRequestContextGetter( |
| 263 new FactoryForMain(profile_io_data, protocol_handlers)); | 240 new FactoryForMain(profile_io_data, protocol_handlers)); |
| 264 } | 241 } |
| 265 | 242 |
| 266 // static | 243 // static |
| 267 ChromeURLRequestContextGetter* | 244 ChromeURLRequestContextGetter* |
| 268 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions( | |
| 269 Profile* profile, const ProfileIOData* profile_io_data) { | |
| 270 DCHECK(profile->IsOffTheRecord()); | |
| 271 return new ChromeURLRequestContextGetter( | |
| 272 new FactoryForExtensions(profile_io_data)); | |
| 273 } | |
| 274 | |
| 275 // static | |
| 276 ChromeURLRequestContextGetter* | |
| 277 ChromeURLRequestContextGetter::CreateOffTheRecordForIsolatedApp( | 245 ChromeURLRequestContextGetter::CreateOffTheRecordForIsolatedApp( |
| 278 Profile* profile, | 246 Profile* profile, |
| 279 const ProfileIOData* profile_io_data, | 247 const ProfileIOData* profile_io_data, |
| 280 const StoragePartitionDescriptor& partition_descriptor, | 248 const StoragePartitionDescriptor& partition_descriptor, |
| 281 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> | 249 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 282 protocol_handler_interceptor, | 250 protocol_handler_interceptor, |
| 283 content::ProtocolHandlerMap* protocol_handlers) { | 251 content::ProtocolHandlerMap* protocol_handlers) { |
| 284 DCHECK(profile->IsOffTheRecord()); | 252 DCHECK(profile->IsOffTheRecord()); |
| 285 ChromeURLRequestContextGetter* main_context = | 253 ChromeURLRequestContextGetter* main_context = |
| 286 static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext()); | 254 static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 309 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 277 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 310 if (load_time_stats_) | 278 if (load_time_stats_) |
| 311 load_time_stats_->UnregisterURLRequestContext(this); | 279 load_time_stats_->UnregisterURLRequestContext(this); |
| 312 } | 280 } |
| 313 | 281 |
| 314 void ChromeURLRequestContext::CopyFrom(ChromeURLRequestContext* other) { | 282 void ChromeURLRequestContext::CopyFrom(ChromeURLRequestContext* other) { |
| 315 URLRequestContext::CopyFrom(other); | 283 URLRequestContext::CopyFrom(other); |
| 316 | 284 |
| 317 // Copy ChromeURLRequestContext parameters. | 285 // Copy ChromeURLRequestContext parameters. |
| 318 } | 286 } |
| OLD | NEW |