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

Unified Diff: net/base/fixed_host_resolver.cc

Issue 345034: Add a command line flag to force all network traffic through a particular ser... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/fixed_host_resolver.h ('k') | net/base/host_resolver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/fixed_host_resolver.cc
===================================================================
--- net/base/fixed_host_resolver.cc (revision 0)
+++ net/base/fixed_host_resolver.cc (revision 0)
@@ -0,0 +1,52 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/base/fixed_host_resolver.h"
+
+#include "net/base/net_errors.h"
+#include "net/base/net_util.h"
+#include "net/base/host_resolver_impl.h"
+
+namespace net {
+
+FixedHostResolver::FixedHostResolver(const std::string& host_and_port)
+ : initialized_(false) {
+ std::string host;
+ int port = 0;
+ if (!ParseHostAndPort(host_and_port, &host, &port)) {
+ LOG(ERROR) << "Invalid FixedHostResolver information: " << host_and_port;
+ return;
+ }
+
+ int rv = SystemHostResolverProc(host, net::ADDRESS_FAMILY_UNSPECIFIED,
+ &address_);
+ if (rv != OK) {
+ LOG(ERROR) << "Could not resolve fixed host: " << host;
+ return;
+ }
+
+ if (port <= 0) {
+ LOG(ERROR) << "FixedHostResolver must contain a port number";
+ return;
+ }
+
+ address_.SetPort(port);
+ initialized_ = true;
+}
+
+int FixedHostResolver::Resolve(const RequestInfo& info,
+ AddressList* addresses,
+ CompletionCallback* callback,
+ RequestHandle* out_req,
+ LoadLog* load_log) {
+ if (!initialized_)
+ return ERR_NAME_NOT_RESOLVED;
+
+ DCHECK(addresses);
+ *addresses = address_;
+ return OK;
+}
+
+} // namespace net
+
Property changes on: net\base\fixed_host_resolver.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « net/base/fixed_host_resolver.h ('k') | net/base/host_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698