Formalize a RenderFrameHost::AddMessageToConsole() API.
[chromium-blink-merge.git] / net / proxy / proxy_resolver_error_observer_mojo.cc
bloba63d5d99ec135d7fb406378e62e2d097252d1c26
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"
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "base/thread_task_runner_handle.h"
10 #include "mojo/common/common_type_converters.h"
12 namespace net {
14 // static
15 scoped_ptr<ProxyResolverErrorObserver> ProxyResolverErrorObserverMojo::Create(
16 interfaces::ProxyResolverErrorObserverPtr error_observer) {
17 if (!error_observer)
18 return nullptr;
20 return scoped_ptr<ProxyResolverErrorObserver>(
21 new ProxyResolverErrorObserverMojo(error_observer.Pass()));
24 void ProxyResolverErrorObserverMojo::OnPACScriptError(
25 int line_number,
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));
31 return;
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()),
40 weak_factory_(this) {
41 weak_this_ = weak_factory_.GetWeakPtr();
44 ProxyResolverErrorObserverMojo::~ProxyResolverErrorObserverMojo() = default;
46 } // namespace net