1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/proxy/proxy_resolver_error_observer_mojo.h"
8 #include "base/location.h"
9 #include "base/thread_task_runner_handle.h"
10 #include "mojo/common/common_type_converters.h"
15 scoped_ptr
<ProxyResolverErrorObserver
> ProxyResolverErrorObserverMojo::Create(
16 interfaces::ProxyResolverErrorObserverPtr error_observer
) {
20 return scoped_ptr
<ProxyResolverErrorObserver
>(
21 new ProxyResolverErrorObserverMojo(error_observer
.Pass()));
24 void ProxyResolverErrorObserverMojo::OnPACScriptError(
26 const base::string16
& error
) {
27 if (!task_runner_
->RunsTasksOnCurrentThread()) {
28 task_runner_
->PostTask(
29 FROM_HERE
, base::Bind(&ProxyResolverErrorObserverMojo::OnPACScriptError
,
30 weak_this_
, line_number
, error
));
33 error_observer_
->OnPacScriptError(line_number
, mojo::String::From(error
));
36 ProxyResolverErrorObserverMojo::ProxyResolverErrorObserverMojo(
37 interfaces::ProxyResolverErrorObserverPtr error_observer
)
38 : error_observer_(error_observer
.Pass()),
39 task_runner_(base::ThreadTaskRunnerHandle::Get()),
41 weak_this_
= weak_factory_
.GetWeakPtr();
44 ProxyResolverErrorObserverMojo::~ProxyResolverErrorObserverMojo() = default;