2012-04-03 03:34:16 +02:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that can
|
|
|
|
// be found in the LICENSE file.
|
|
|
|
|
2015-11-26 03:53:12 +01:00
|
|
|
#include "libcef/browser/net/url_request_context_getter_proxy.h"
|
|
|
|
|
|
|
|
#include "libcef/browser/net/url_request_context_getter.h"
|
|
|
|
#include "libcef/browser/net/url_request_context_proxy.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "libcef/browser/thread_util.h"
|
|
|
|
|
|
|
|
CefURLRequestContextGetterProxy::CefURLRequestContextGetterProxy(
|
2013-09-03 18:43:31 +02:00
|
|
|
CefRefPtr<CefRequestContextHandler> handler,
|
2015-02-14 00:17:08 +01:00
|
|
|
scoped_refptr<CefURLRequestContextGetterImpl> parent)
|
2017-05-17 11:29:28 +02:00
|
|
|
: handler_(handler), parent_(parent) {
|
2015-03-02 21:25:14 +01:00
|
|
|
DCHECK(handler_.get());
|
|
|
|
DCHECK(parent_.get());
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2012-06-28 19:21:18 +02:00
|
|
|
CefURLRequestContextGetterProxy::~CefURLRequestContextGetterProxy() {
|
2012-12-04 02:12:11 +01:00
|
|
|
CEF_REQUIRE_IOT();
|
2012-06-28 19:21:18 +02:00
|
|
|
}
|
|
|
|
|
2017-04-20 21:28:17 +02:00
|
|
|
void CefURLRequestContextGetterProxy::ShutdownOnUIThread() {
|
|
|
|
CEF_REQUIRE_UIT();
|
2017-05-17 11:29:28 +02:00
|
|
|
CEF_POST_TASK(
|
|
|
|
CEF_IOT,
|
2017-04-20 21:28:17 +02:00
|
|
|
base::Bind(&CefURLRequestContextGetterProxy::ShutdownOnIOThread, this));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefURLRequestContextGetterProxy::ShutdownOnIOThread() {
|
|
|
|
CEF_REQUIRE_IOT();
|
|
|
|
shutting_down_ = true;
|
|
|
|
context_proxy_.reset();
|
|
|
|
NotifyContextShuttingDown();
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
net::URLRequestContext*
|
2017-05-17 11:29:28 +02:00
|
|
|
CefURLRequestContextGetterProxy::GetURLRequestContext() {
|
2012-04-03 03:34:16 +02:00
|
|
|
CEF_REQUIRE_IOT();
|
2017-04-20 21:28:17 +02:00
|
|
|
|
|
|
|
if (shutting_down_)
|
|
|
|
return nullptr;
|
|
|
|
|
2012-06-28 19:21:18 +02:00
|
|
|
if (!context_proxy_) {
|
2017-05-17 11:29:28 +02:00
|
|
|
context_proxy_.reset(new CefURLRequestContextProxy(
|
|
|
|
static_cast<CefURLRequestContextImpl*>(parent_->GetURLRequestContext()),
|
|
|
|
handler_));
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
2015-02-14 00:17:08 +01:00
|
|
|
return context_proxy_.get();
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2012-06-22 00:50:34 +02:00
|
|
|
scoped_refptr<base::SingleThreadTaskRunner>
|
2017-05-17 11:29:28 +02:00
|
|
|
CefURLRequestContextGetterProxy::GetNetworkTaskRunner() const {
|
2012-06-22 00:50:34 +02:00
|
|
|
return parent_->GetNetworkTaskRunner();
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
2013-09-03 18:43:31 +02:00
|
|
|
|
|
|
|
net::HostResolver* CefURLRequestContextGetterProxy::GetHostResolver() const {
|
2015-02-14 00:17:08 +01:00
|
|
|
return parent_->GetHostResolver();
|
2013-09-03 18:43:31 +02:00
|
|
|
}
|