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

Side by Side Diff: net/dns/dns_client.cc

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « net/dns/dns_client.h ('k') | net/dns/dns_config_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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.
4
5 #include "net/dns/dns_client.h"
6
7 #include "base/bind.h"
8 #include "base/rand_util.h"
9 #include "net/base/net_log.h"
10 #include "net/dns/address_sorter.h"
11 #include "net/dns/dns_config_service.h"
12 #include "net/dns/dns_session.h"
13 #include "net/dns/dns_socket_pool.h"
14 #include "net/dns/dns_transaction.h"
15 #include "net/socket/client_socket_factory.h"
16
17 namespace net {
18
19 namespace {
20
21 class DnsClientImpl : public DnsClient {
22 public:
23 explicit DnsClientImpl(NetLog* net_log)
24 : address_sorter_(AddressSorter::CreateAddressSorter()),
25 net_log_(net_log) {}
26
27 void SetConfig(const DnsConfig& config) override {
28 factory_.reset();
29 session_ = NULL;
30 if (config.IsValid() && !config.unhandled_options) {
31 ClientSocketFactory* factory = ClientSocketFactory::GetDefaultFactory();
32 scoped_ptr<DnsSocketPool> socket_pool(
33 config.randomize_ports ? DnsSocketPool::CreateDefault(factory)
34 : DnsSocketPool::CreateNull(factory));
35 session_ = new DnsSession(config,
36 socket_pool.Pass(),
37 base::Bind(&base::RandInt),
38 net_log_);
39 factory_ = DnsTransactionFactory::CreateFactory(session_.get());
40 }
41 }
42
43 const DnsConfig* GetConfig() const override {
44 return session_.get() ? &session_->config() : NULL;
45 }
46
47 DnsTransactionFactory* GetTransactionFactory() override {
48 return session_.get() ? factory_.get() : NULL;
49 }
50
51 AddressSorter* GetAddressSorter() override { return address_sorter_.get(); }
52
53 private:
54 scoped_refptr<DnsSession> session_;
55 scoped_ptr<DnsTransactionFactory> factory_;
56 scoped_ptr<AddressSorter> address_sorter_;
57
58 NetLog* net_log_;
59 };
60
61 } // namespace
62
63 // static
64 scoped_ptr<DnsClient> DnsClient::CreateClient(NetLog* net_log) {
65 return scoped_ptr<DnsClient>(new DnsClientImpl(net_log));
66 }
67
68 } // namespace net
69
OLDNEW
« no previous file with comments | « net/dns/dns_client.h ('k') | net/dns/dns_config_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698