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

Side by Side Diff: net/proxy/mojo_proxy_resolver_v8_tracing_bindings.h

Issue 2416483002: Use std::string instead of mojo::String in //net. (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_PROXY_MOJO_PROXY_RESOLVER_V8_TRACING_BINDINGS_H_ 5 #ifndef NET_PROXY_MOJO_PROXY_RESOLVER_V8_TRACING_BINDINGS_H_
6 #define NET_PROXY_MOJO_PROXY_RESOLVER_V8_TRACING_BINDINGS_H_ 6 #define NET_PROXY_MOJO_PROXY_RESOLVER_V8_TRACING_BINDINGS_H_
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/strings/utf_string_conversions.h"
10 #include "base/threading/thread_checker.h" 11 #include "base/threading/thread_checker.h"
11 #include "mojo/common/common_type_converters.h"
12 #include "net/dns/host_resolver_mojo.h" 12 #include "net/dns/host_resolver_mojo.h"
13 #include "net/interfaces/proxy_resolver_service.mojom.h" 13 #include "net/interfaces/proxy_resolver_service.mojom.h"
14 #include "net/log/net_log_with_source.h" 14 #include "net/log/net_log_with_source.h"
15 #include "net/proxy/proxy_resolver_v8_tracing.h" 15 #include "net/proxy/proxy_resolver_v8_tracing.h"
16 16
17 namespace net { 17 namespace net {
18 18
19 // An implementation of ProxyResolverV8Tracing::Bindings that forwards requests 19 // An implementation of ProxyResolverV8Tracing::Bindings that forwards requests
20 // onto a Client mojo interface. Alert() and OnError() may be called from any 20 // onto a Client mojo interface. Alert() and OnError() may be called from any
21 // thread; when they are called from another thread, the calls are proxied to 21 // thread; when they are called from another thread, the calls are proxied to
22 // the origin task runner. GetHostResolver() and GetNetLogWithSource() may only 22 // the origin task runner. GetHostResolver() and GetNetLogWithSource() may only
23 // be 23 // be
24 // called from the origin task runner. 24 // called from the origin task runner.
25 template <typename Client> 25 template <typename Client>
26 class MojoProxyResolverV8TracingBindings 26 class MojoProxyResolverV8TracingBindings
27 : public ProxyResolverV8Tracing::Bindings, 27 : public ProxyResolverV8Tracing::Bindings,
28 public HostResolverMojo::Impl { 28 public HostResolverMojo::Impl {
29 public: 29 public:
30 explicit MojoProxyResolverV8TracingBindings(Client* client) 30 explicit MojoProxyResolverV8TracingBindings(Client* client)
31 : client_(client), host_resolver_(this) { 31 : client_(client), host_resolver_(this) {
32 DCHECK(client_); 32 DCHECK(client_);
33 } 33 }
34 34
35 // ProxyResolverV8Tracing::Bindings overrides. 35 // ProxyResolverV8Tracing::Bindings overrides.
36 void Alert(const base::string16& message) override { 36 void Alert(const base::string16& message) override {
37 DCHECK(thread_checker_.CalledOnValidThread()); 37 DCHECK(thread_checker_.CalledOnValidThread());
38 client_->Alert(mojo::String::From(message)); 38 client_->Alert(base::UTF16ToUTF8(message));
39 } 39 }
40 40
41 void OnError(int line_number, const base::string16& message) override { 41 void OnError(int line_number, const base::string16& message) override {
42 DCHECK(thread_checker_.CalledOnValidThread()); 42 DCHECK(thread_checker_.CalledOnValidThread());
43 client_->OnError(line_number, mojo::String::From(message)); 43 client_->OnError(line_number, base::UTF16ToUTF8(message));
44 } 44 }
45 45
46 HostResolver* GetHostResolver() override { 46 HostResolver* GetHostResolver() override {
47 DCHECK(thread_checker_.CalledOnValidThread()); 47 DCHECK(thread_checker_.CalledOnValidThread());
48 return &host_resolver_; 48 return &host_resolver_;
49 } 49 }
50 50
51 NetLogWithSource GetNetLogWithSource() override { 51 NetLogWithSource GetNetLogWithSource() override {
52 DCHECK(thread_checker_.CalledOnValidThread()); 52 DCHECK(thread_checker_.CalledOnValidThread());
53 return NetLogWithSource(); 53 return NetLogWithSource();
54 } 54 }
55 55
56 private: 56 private:
57 // HostResolverMojo::Impl override. 57 // HostResolverMojo::Impl override.
58 void ResolveDns(std::unique_ptr<HostResolver::RequestInfo> request_info, 58 void ResolveDns(std::unique_ptr<HostResolver::RequestInfo> request_info,
59 interfaces::HostResolverRequestClientPtr client) { 59 interfaces::HostResolverRequestClientPtr client) {
60 DCHECK(thread_checker_.CalledOnValidThread()); 60 DCHECK(thread_checker_.CalledOnValidThread());
61 client_->ResolveDns(std::move(request_info), std::move(client)); 61 client_->ResolveDns(std::move(request_info), std::move(client));
62 } 62 }
63 63
64 base::ThreadChecker thread_checker_; 64 base::ThreadChecker thread_checker_;
65 Client* client_; 65 Client* client_;
66 HostResolverMojo host_resolver_; 66 HostResolverMojo host_resolver_;
67 }; 67 };
68 68
69 } // namespace net 69 } // namespace net
70 70
71 #endif // NET_PROXY_MOJO_PROXY_RESOLVER_V8_TRACING_BINDINGS_H_ 71 #endif // NET_PROXY_MOJO_PROXY_RESOLVER_V8_TRACING_BINDINGS_H_
OLDNEW
« no previous file with comments | « net/proxy/mojo_proxy_resolver_impl_unittest.cc ('k') | net/proxy/mojo_proxy_resolver_v8_tracing_bindings_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698