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