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 #ifndef NET_PROXY_PROXY_RESOLVER_ERROR_OBSERVER_MOJO_H_
6 #define NET_PROXY_PROXY_RESOLVER_ERROR_OBSERVER_MOJO_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/single_thread_task_runner.h"
12 #include "net/interfaces/proxy_resolver_service.mojom.h"
13 #include "net/proxy/proxy_resolver_error_observer.h"
17 // An implementation of ProxyResolverErrorObserver that forwards errors to an
18 // interfaces::ProxyResolverErrorObserver mojo interface.
19 class ProxyResolverErrorObserverMojo
: public ProxyResolverErrorObserver
{
21 static scoped_ptr
<ProxyResolverErrorObserver
> Create(
22 interfaces::ProxyResolverErrorObserverPtr error_observer
);
24 void OnPACScriptError(int line_number
, const base::string16
& error
) override
;
27 explicit ProxyResolverErrorObserverMojo(
28 interfaces::ProxyResolverErrorObserverPtr error_observer
);
29 ~ProxyResolverErrorObserverMojo() override
;
31 // |error_observer_| may only be accessed when running on |task_runner_|.
32 interfaces::ProxyResolverErrorObserverPtr error_observer_
;
33 scoped_refptr
<base::SingleThreadTaskRunner
> task_runner_
;
35 // Creating a new WeakPtr is only valid on the original thread, but copying an
36 // existing WeakPtr is valid on any thread so keep |weak_this_| ready to copy.
37 base::WeakPtr
<ProxyResolverErrorObserverMojo
> weak_this_
;
38 base::WeakPtrFactory
<ProxyResolverErrorObserverMojo
> weak_factory_
;
43 #endif // NET_PROXY_PROXY_RESOLVER_ERROR_OBSERVER_MOJO_H_