Remove linux_chromium_gn_dbg from the chromium CQ.
[chromium-blink-merge.git] / net / proxy / mojo_proxy_resolver_v8_tracing_bindings.h
blob70ebe3c49837134afe009e07c94cc81e9d9c09a2
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_MOJO_PROXY_RESOLVER_V8_TRACING_BINDINGS_H_
6 #define NET_PROXY_MOJO_PROXY_RESOLVER_V8_TRACING_BINDINGS_H_
8 #include "base/threading/thread_checker.h"
9 #include "mojo/common/common_type_converters.h"
10 #include "net/dns/host_resolver_mojo.h"
11 #include "net/interfaces/proxy_resolver_service.mojom.h"
12 #include "net/proxy/proxy_resolver_v8_tracing.h"
14 namespace net {
16 // An implementation of ProxyResolverV8Tracing::Bindings that forwards requests
17 // onto a Client mojo interface. Alert() and OnError() may be called from any
18 // thread; when they are called from another thread, the calls are proxied to
19 // the origin task runner. GetHostResolver() and GetBoundNetLog() may only be
20 // called from the origin task runner.
21 template <typename Client>
22 class MojoProxyResolverV8TracingBindings
23 : public ProxyResolverV8Tracing::Bindings,
24 public HostResolverMojo::Impl {
25 public:
26 explicit MojoProxyResolverV8TracingBindings(Client* client)
27 : client_(client), host_resolver_(this) {
28 DCHECK(client_);
31 // ProxyResolverV8Tracing::Bindings overrides.
32 void Alert(const base::string16& message) override {
33 DCHECK(thread_checker_.CalledOnValidThread());
34 client_->Alert(mojo::String::From(message));
37 void OnError(int line_number, const base::string16& message) override {
38 DCHECK(thread_checker_.CalledOnValidThread());
39 client_->OnError(line_number, mojo::String::From(message));
42 HostResolver* GetHostResolver() override {
43 DCHECK(thread_checker_.CalledOnValidThread());
44 return &host_resolver_;
47 BoundNetLog GetBoundNetLog() override {
48 DCHECK(thread_checker_.CalledOnValidThread());
49 return BoundNetLog();
52 private:
53 // HostResolverMojo::Impl override.
54 void ResolveDns(interfaces::HostResolverRequestInfoPtr request_info,
55 interfaces::HostResolverRequestClientPtr client) {
56 DCHECK(thread_checker_.CalledOnValidThread());
57 client_->ResolveDns(request_info.Pass(), client.Pass());
60 base::ThreadChecker thread_checker_;
61 Client* client_;
62 HostResolverMojo host_resolver_;
65 } // namespace net
67 #endif // NET_PROXY_MOJO_PROXY_RESOLVER_V8_TRACING_BINDINGS_H_