mirror of
				https://bitbucket.org/chromiumembedded/cef
				synced 2025-06-05 21:39:12 +02:00 
			
		
		
		
	- Simplify and document the relationship between the various context object types. See browser_context.h for a description of the new relationships. - cefclient: Add `request-context-per-browser` command-line flag for testing multiple CefRequestContext instances. - cefclient: Add a CefURLRequest example. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@2032 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
		| @@ -10,47 +10,15 @@ | ||||
| #include "libcef/browser/context.h" | ||||
| #include "libcef/browser/download_manager_delegate.h" | ||||
| #include "libcef/browser/thread_util.h" | ||||
| #include "libcef/browser/url_request_context_getter.h" | ||||
|  | ||||
| #include "base/bind.h" | ||||
| #include "base/logging.h" | ||||
| #include "base/threading/thread.h" | ||||
| #include "components/keyed_service/content/browser_context_dependency_manager.h" | ||||
| #include "content/public/browser/download_manager.h" | ||||
| #include "content/public/browser/browser_thread.h" | ||||
| #include "content/public/browser/resource_context.h" | ||||
| #include "content/public/browser/storage_partition.h" | ||||
|  | ||||
| using content::BrowserThread; | ||||
|  | ||||
| class CefBrowserContextImpl::CefResourceContext : public content::ResourceContext { | ||||
|  public: | ||||
|   CefResourceContext() : getter_(NULL) {} | ||||
|  | ||||
|   // ResourceContext implementation: | ||||
|   net::HostResolver* GetHostResolver() override { | ||||
|     CHECK(getter_); | ||||
|     return getter_->host_resolver(); | ||||
|   } | ||||
|   net::URLRequestContext* GetRequestContext() override { | ||||
|     CHECK(getter_); | ||||
|     return getter_->GetURLRequestContext(); | ||||
|   } | ||||
|  | ||||
|   void set_url_request_context_getter(CefURLRequestContextGetter* getter) { | ||||
|     getter_ = getter; | ||||
|   } | ||||
|  | ||||
|  private: | ||||
|   CefURLRequestContextGetter* getter_; | ||||
|  | ||||
|   DISALLOW_COPY_AND_ASSIGN(CefResourceContext); | ||||
| }; | ||||
|  | ||||
| CefBrowserContextImpl::CefBrowserContextImpl() | ||||
|     : resource_context_(new CefResourceContext) { | ||||
|   BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices( | ||||
|       this); | ||||
| CefBrowserContextImpl::CefBrowserContextImpl() { | ||||
| } | ||||
|  | ||||
| CefBrowserContextImpl::~CefBrowserContextImpl() { | ||||
| @@ -58,15 +26,6 @@ CefBrowserContextImpl::~CefBrowserContextImpl() { | ||||
|   // when it's accessed from the content::BrowserContext destructor. | ||||
|   if (download_manager_delegate_.get()) | ||||
|     download_manager_delegate_.reset(NULL); | ||||
|  | ||||
|   if (resource_context_.get()) { | ||||
|     BrowserThread::DeleteSoon( | ||||
|         BrowserThread::IO, FROM_HERE, resource_context_.release()); | ||||
|   } | ||||
|  | ||||
|   // Remove any BrowserContextKeyedServiceFactory associations. | ||||
|   BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices( | ||||
|       this); | ||||
| } | ||||
|  | ||||
| base::FilePath CefBrowserContextImpl::GetPath() const { | ||||
| @@ -120,10 +79,6 @@ net::URLRequestContextGetter* | ||||
|   return GetRequestContext(); | ||||
| } | ||||
|  | ||||
| content::ResourceContext* CefBrowserContextImpl::GetResourceContext() { | ||||
|   return resource_context_.get(); | ||||
| } | ||||
|  | ||||
| content::BrowserPluginGuestManager* CefBrowserContextImpl::GetGuestManager() { | ||||
|   return NULL; | ||||
| } | ||||
| @@ -147,12 +102,12 @@ net::URLRequestContextGetter* CefBrowserContextImpl::CreateRequestContext( | ||||
|     content::ProtocolHandlerMap* protocol_handlers, | ||||
|     content::URLRequestInterceptorScopedVector request_interceptors) { | ||||
|   DCHECK(!url_request_getter_.get()); | ||||
|   url_request_getter_ = new CefURLRequestContextGetter( | ||||
|   url_request_getter_ = new CefURLRequestContextGetterImpl( | ||||
|       BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::IO), | ||||
|       BrowserThread::UnsafeGetMessageLoopForThread(BrowserThread::FILE), | ||||
|       protocol_handlers, | ||||
|       request_interceptors.Pass()); | ||||
|   resource_context_->set_url_request_context_getter(url_request_getter_.get()); | ||||
|   resource_context()->set_url_request_context_getter(url_request_getter_.get()); | ||||
|   return url_request_getter_.get(); | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user