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.h" | 9 #include "base/message_loop.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 return profile_io_data_->GetExtensionsRequestContext(); | 61 return profile_io_data_->GetExtensionsRequestContext(); |
62 } | 62 } |
63 | 63 |
64 private: | 64 private: |
65 const ProfileIOData* const profile_io_data_; | 65 const ProfileIOData* const profile_io_data_; |
66 }; | 66 }; |
67 | 67 |
68 // Factory that creates the ChromeURLRequestContext for a given isolated app. | 68 // Factory that creates the ChromeURLRequestContext for a given isolated app. |
69 class FactoryForIsolatedApp : public ChromeURLRequestContextFactory { | 69 class FactoryForIsolatedApp : public ChromeURLRequestContextFactory { |
70 public: | 70 public: |
71 FactoryForIsolatedApp(const ProfileIOData* profile_io_data, | 71 FactoryForIsolatedApp( |
72 const StoragePartitionDescriptor& partition_descriptor, | 72 const ProfileIOData* profile_io_data, |
73 ChromeURLRequestContextGetter* main_context, | 73 const StoragePartitionDescriptor& partition_descriptor, |
74 scoped_ptr<net::URLRequestJobFactory::Interceptor> | 74 ChromeURLRequestContextGetter* main_context, |
75 protocol_handler_interceptor) | 75 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
| 76 protocol_handler_interceptor) |
76 : profile_io_data_(profile_io_data), | 77 : profile_io_data_(profile_io_data), |
77 partition_descriptor_(partition_descriptor), | 78 partition_descriptor_(partition_descriptor), |
78 main_request_context_getter_(main_context), | 79 main_request_context_getter_(main_context), |
79 protocol_handler_interceptor_(protocol_handler_interceptor.Pass()) {} | 80 protocol_handler_interceptor_(protocol_handler_interceptor.Pass()) {} |
80 | 81 |
81 virtual ChromeURLRequestContext* Create() OVERRIDE { | 82 virtual ChromeURLRequestContext* Create() OVERRIDE { |
82 // We will copy most of the state from the main request context. | 83 // We will copy most of the state from the main request context. |
83 // | 84 // |
84 // Note that this factory is one-shot. After Create() is called once, the | 85 // Note that this factory is one-shot. After Create() is called once, the |
85 // factory is actually destroyed. Thus it is safe to destructively pass | 86 // factory is actually destroyed. Thus it is safe to destructively pass |
86 // state onwards. | 87 // state onwards. |
87 return profile_io_data_->GetIsolatedAppRequestContext( | 88 return profile_io_data_->GetIsolatedAppRequestContext( |
88 main_request_context_getter_->GetIOContext(), partition_descriptor_, | 89 main_request_context_getter_->GetIOContext(), partition_descriptor_, |
89 protocol_handler_interceptor_.Pass()); | 90 protocol_handler_interceptor_.Pass()); |
90 } | 91 } |
91 | 92 |
92 private: | 93 private: |
93 const ProfileIOData* const profile_io_data_; | 94 const ProfileIOData* const profile_io_data_; |
94 const StoragePartitionDescriptor partition_descriptor_; | 95 const StoragePartitionDescriptor partition_descriptor_; |
95 scoped_refptr<ChromeURLRequestContextGetter> | 96 scoped_refptr<ChromeURLRequestContextGetter> |
96 main_request_context_getter_; | 97 main_request_context_getter_; |
97 scoped_ptr<net::URLRequestJobFactory::Interceptor> | 98 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
98 protocol_handler_interceptor_; | 99 protocol_handler_interceptor_; |
99 }; | 100 }; |
100 | 101 |
101 // Factory that creates the media ChromeURLRequestContext for a given isolated | 102 // Factory that creates the media ChromeURLRequestContext for a given isolated |
102 // app. The media context is based on the corresponding isolated app's context. | 103 // app. The media context is based on the corresponding isolated app's context. |
103 class FactoryForIsolatedMedia : public ChromeURLRequestContextFactory { | 104 class FactoryForIsolatedMedia : public ChromeURLRequestContextFactory { |
104 public: | 105 public: |
105 FactoryForIsolatedMedia( | 106 FactoryForIsolatedMedia( |
106 const ProfileIOData* profile_io_data, | 107 const ProfileIOData* profile_io_data, |
107 const StoragePartitionDescriptor& partition_descriptor, | 108 const StoragePartitionDescriptor& partition_descriptor, |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 return new ChromeURLRequestContextGetter( | 205 return new ChromeURLRequestContextGetter( |
205 new FactoryForExtensions(profile_io_data)); | 206 new FactoryForExtensions(profile_io_data)); |
206 } | 207 } |
207 | 208 |
208 // static | 209 // static |
209 ChromeURLRequestContextGetter* | 210 ChromeURLRequestContextGetter* |
210 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( | 211 ChromeURLRequestContextGetter::CreateOriginalForIsolatedApp( |
211 Profile* profile, | 212 Profile* profile, |
212 const ProfileIOData* profile_io_data, | 213 const ProfileIOData* profile_io_data, |
213 const StoragePartitionDescriptor& partition_descriptor, | 214 const StoragePartitionDescriptor& partition_descriptor, |
214 scoped_ptr<net::URLRequestJobFactory::Interceptor> | 215 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
215 protocol_handler_interceptor) { | 216 protocol_handler_interceptor) { |
216 DCHECK(!profile->IsOffTheRecord()); | 217 DCHECK(!profile->IsOffTheRecord()); |
217 ChromeURLRequestContextGetter* main_context = | 218 ChromeURLRequestContextGetter* main_context = |
218 static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext()); | 219 static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext()); |
219 return new ChromeURLRequestContextGetter( | 220 return new ChromeURLRequestContextGetter( |
220 new FactoryForIsolatedApp(profile_io_data, partition_descriptor, | 221 new FactoryForIsolatedApp(profile_io_data, partition_descriptor, |
221 main_context, protocol_handler_interceptor.Pass())); | 222 main_context, protocol_handler_interceptor.Pass())); |
222 } | 223 } |
223 | 224 |
224 // static | 225 // static |
(...skipping 26 matching lines...) Expand all Loading... |
251 return new ChromeURLRequestContextGetter( | 252 return new ChromeURLRequestContextGetter( |
252 new FactoryForExtensions(profile_io_data)); | 253 new FactoryForExtensions(profile_io_data)); |
253 } | 254 } |
254 | 255 |
255 // static | 256 // static |
256 ChromeURLRequestContextGetter* | 257 ChromeURLRequestContextGetter* |
257 ChromeURLRequestContextGetter::CreateOffTheRecordForIsolatedApp( | 258 ChromeURLRequestContextGetter::CreateOffTheRecordForIsolatedApp( |
258 Profile* profile, | 259 Profile* profile, |
259 const ProfileIOData* profile_io_data, | 260 const ProfileIOData* profile_io_data, |
260 const StoragePartitionDescriptor& partition_descriptor, | 261 const StoragePartitionDescriptor& partition_descriptor, |
261 scoped_ptr<net::URLRequestJobFactory::Interceptor> | 262 scoped_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> |
262 protocol_handler_interceptor) { | 263 protocol_handler_interceptor) { |
263 DCHECK(profile->IsOffTheRecord()); | 264 DCHECK(profile->IsOffTheRecord()); |
264 ChromeURLRequestContextGetter* main_context = | 265 ChromeURLRequestContextGetter* main_context = |
265 static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext()); | 266 static_cast<ChromeURLRequestContextGetter*>(profile->GetRequestContext()); |
266 return new ChromeURLRequestContextGetter( | 267 return new ChromeURLRequestContextGetter( |
267 new FactoryForIsolatedApp(profile_io_data, partition_descriptor, | 268 new FactoryForIsolatedApp(profile_io_data, partition_descriptor, |
268 main_context, protocol_handler_interceptor.Pass())); | 269 main_context, protocol_handler_interceptor.Pass())); |
269 } | 270 } |
270 | 271 |
271 // ---------------------------------------------------------------------------- | 272 // ---------------------------------------------------------------------------- |
(...skipping 29 matching lines...) Expand all Loading... |
301 ChromeURLDataManagerBackend* | 302 ChromeURLDataManagerBackend* |
302 ChromeURLRequestContext::chrome_url_data_manager_backend() const { | 303 ChromeURLRequestContext::chrome_url_data_manager_backend() const { |
303 return chrome_url_data_manager_backend_; | 304 return chrome_url_data_manager_backend_; |
304 } | 305 } |
305 | 306 |
306 void ChromeURLRequestContext::set_chrome_url_data_manager_backend( | 307 void ChromeURLRequestContext::set_chrome_url_data_manager_backend( |
307 ChromeURLDataManagerBackend* backend) { | 308 ChromeURLDataManagerBackend* backend) { |
308 DCHECK(backend); | 309 DCHECK(backend); |
309 chrome_url_data_manager_backend_ = backend; | 310 chrome_url_data_manager_backend_ = backend; |
310 } | 311 } |
OLD | NEW |