Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: net/proxy/mojo_proxy_resolver_impl.cc

Issue 939503004: Add LoadState reporting to the mojo proxy resolver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@proxy-resolver-mojo
Patch Set: rebase Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/proxy/mojo_proxy_resolver_impl.h ('k') | net/proxy/mojo_proxy_resolver_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/mojo_proxy_resolver_impl.cc
diff --git a/net/proxy/mojo_proxy_resolver_impl.cc b/net/proxy/mojo_proxy_resolver_impl.cc
index f59cb1e9eed8c867bdc2a466f7d918ab7af6d404..8d93fc6e26860b3ae84a9021f5475757508919f9 100644
--- a/net/proxy/mojo_proxy_resolver_impl.cc
+++ b/net/proxy/mojo_proxy_resolver_impl.cc
@@ -10,7 +10,6 @@
#include "net/base/net_log.h"
#include "net/proxy/mojo_proxy_type_converters.h"
#include "net/proxy/proxy_info.h"
-#include "net/proxy/proxy_resolver.h"
#include "net/proxy/proxy_resolver_script_data.h"
namespace net {
@@ -24,6 +23,11 @@ class MojoProxyResolverImpl::Job : public mojo::ErrorHandler {
void Start();
+ // Invoked when the LoadState for this job changes.
+ void LoadStateChanged(LoadState load_state);
+
+ net::ProxyResolver::RequestHandle request_handle() { return request_handle_; }
+
private:
// mojo::ErrorHandler override.
// This is invoked in response to the client disconnecting, indicating
@@ -38,6 +42,7 @@ class MojoProxyResolverImpl::Job : public mojo::ErrorHandler {
ProxyInfo result_;
GURL url_;
net::ProxyResolver::RequestHandle request_handle_;
+ bool done_;
DISALLOW_COPY_AND_ASSIGN(Job);
};
@@ -54,6 +59,14 @@ MojoProxyResolverImpl::~MojoProxyResolverImpl() {
STLDeleteElements(&resolve_jobs_);
}
+void MojoProxyResolverImpl::LoadStateChanged(
+ net::ProxyResolver::RequestHandle handle,
+ LoadState load_state) {
+ auto it = request_handle_to_job_.find(handle);
+ DCHECK(it != request_handle_to_job_.end());
+ it->second->LoadStateChanged(load_state);
+}
+
void MojoProxyResolverImpl::SetPacScript(
const mojo::String& data,
const mojo::Callback<void(int32_t)>& callback) {
@@ -75,6 +88,9 @@ void MojoProxyResolverImpl::GetProxyForUrl(
}
void MojoProxyResolverImpl::DeleteJob(Job* job) {
+ if (job->request_handle())
+ request_handle_to_job_.erase(job->request_handle());
+
size_t num_erased = resolve_jobs_.erase(job);
DCHECK(num_erased);
delete job;
@@ -106,11 +122,12 @@ MojoProxyResolverImpl::Job::Job(
: resolver_(resolver),
client_(client.Pass()),
url_(url),
- request_handle_(nullptr) {
+ request_handle_(nullptr),
+ done_(false) {
}
MojoProxyResolverImpl::Job::~Job() {
- if (request_handle_)
+ if (request_handle_ && !done_)
resolver_->resolver_->CancelRequest(request_handle_);
}
@@ -123,10 +140,16 @@ void MojoProxyResolverImpl::Job::Start() {
return;
}
client_.set_error_handler(this);
+ resolver_->request_handle_to_job_.insert(
+ std::make_pair(request_handle_, this));
+}
+
+void MojoProxyResolverImpl::Job::LoadStateChanged(LoadState load_state) {
+ client_->LoadStateChanged(load_state);
}
void MojoProxyResolverImpl::Job::GetProxyDone(int error) {
- request_handle_ = nullptr;
+ done_ = true;
DVLOG(1) << "GetProxyForUrl(" << url_ << ") finished with error " << error
<< ". " << result_.proxy_list().size() << " Proxies returned:";
for (const auto& proxy : result_.proxy_list().GetAll()) {
« no previous file with comments | « net/proxy/mojo_proxy_resolver_impl.h ('k') | net/proxy/mojo_proxy_resolver_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698