Pass parameter by pointers when creating job factory.
1. The caller needs to modify protocol_handlers. 2. We need to make sure protocol_handlers and interceptors are not touched if user doesn't create a job factory.
This commit is contained in:
		
					parent
					
						
							
								604361f93d
							
						
					
				
			
			
				commit
				
					
						da3bafd490
					
				
			
		
					 4 changed files with 7 additions and 9 deletions
				
			
		|  | @ -122,8 +122,8 @@ scoped_ptr<NetworkDelegate> BrowserContext::CreateNetworkDelegate() { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| scoped_ptr<net::URLRequestJobFactory> BrowserContext::CreateURLRequestJobFactory( | scoped_ptr<net::URLRequestJobFactory> BrowserContext::CreateURLRequestJobFactory( | ||||||
|     const content::ProtocolHandlerMap& protocol_handlers, |     content::ProtocolHandlerMap* protocol_handlers, | ||||||
|     content::ProtocolHandlerScopedVector protocol_interceptors) { |     content::ProtocolHandlerScopedVector* protocol_interceptors) { | ||||||
|   return scoped_ptr<net::URLRequestJobFactory>(); |   return scoped_ptr<net::URLRequestJobFactory>(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -50,8 +50,8 @@ class BrowserContext : public content::BrowserContext { | ||||||
|   // Subclasses should override this to provide a custom URLRequestJobFactory
 |   // Subclasses should override this to provide a custom URLRequestJobFactory
 | ||||||
|   // implementation.
 |   // implementation.
 | ||||||
|   virtual scoped_ptr<net::URLRequestJobFactory> CreateURLRequestJobFactory( |   virtual scoped_ptr<net::URLRequestJobFactory> CreateURLRequestJobFactory( | ||||||
|       const content::ProtocolHandlerMap& protocol_handlers, |       content::ProtocolHandlerMap* protocol_handlers, | ||||||
|       content::ProtocolHandlerScopedVector protocol_interceptors); |       content::ProtocolHandlerScopedVector* protocol_interceptors); | ||||||
| 
 | 
 | ||||||
|   virtual base::FilePath GetPath() const OVERRIDE; |   virtual base::FilePath GetPath() const OVERRIDE; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -153,11 +153,9 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { | ||||||
| 
 | 
 | ||||||
|     // Give user a chance to create their own job factory.
 |     // Give user a chance to create their own job factory.
 | ||||||
|     scoped_ptr<net::URLRequestJobFactory> user_job_factory( |     scoped_ptr<net::URLRequestJobFactory> user_job_factory( | ||||||
|         job_factory_factory_.Run(protocol_handlers_, protocol_interceptors_.Pass())); |         job_factory_factory_.Run(&protocol_handlers_, &protocol_interceptors_)); | ||||||
|     if (user_job_factory) { |     if (user_job_factory) { | ||||||
|       storage_->set_job_factory(user_job_factory.release()); |       storage_->set_job_factory(user_job_factory.release()); | ||||||
|       protocol_handlers_.clear(); |  | ||||||
|       protocol_interceptors_.weak_clear(); |  | ||||||
|       return url_request_context_.get(); |       return url_request_context_.get(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -26,8 +26,8 @@ namespace brightray { | ||||||
| class NetworkDelegate; | class NetworkDelegate; | ||||||
| 
 | 
 | ||||||
| typedef base::Callback<scoped_ptr<net::URLRequestJobFactory>( | typedef base::Callback<scoped_ptr<net::URLRequestJobFactory>( | ||||||
|     const content::ProtocolHandlerMap& protocol_handlers, |     content::ProtocolHandlerMap* protocol_handlers, | ||||||
|     content::ProtocolHandlerScopedVector protocol_interceptors)> URLRequestJobFactoryFactory; |     content::ProtocolHandlerScopedVector* protocol_interceptors)> URLRequestJobFactoryFactory; | ||||||
| 
 | 
 | ||||||
| class URLRequestContextGetter : public net::URLRequestContextGetter { | class URLRequestContextGetter : public net::URLRequestContextGetter { | ||||||
|  public: |  public: | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Cheng Zhao
				Cheng Zhao