Enabling tests which should be fixed by r173829.
[chromium-blink-merge.git] / net / proxy / proxy_resolver_script_data.cc
blobdbe1e321e5b0779baefc1468b1f42870d106046e
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.
5 #include "net/proxy/proxy_resolver_script_data.h"
7 #include "base/logging.h"
8 #include "base/utf_string_conversions.h"
10 namespace net {
12 // static
13 scoped_refptr<ProxyResolverScriptData> ProxyResolverScriptData::FromUTF8(
14 const std::string& utf8) {
15 return new ProxyResolverScriptData(TYPE_SCRIPT_CONTENTS,
16 GURL(),
17 UTF8ToUTF16(utf8));
20 // static
21 scoped_refptr<ProxyResolverScriptData> ProxyResolverScriptData::FromUTF16(
22 const string16& utf16) {
23 return new ProxyResolverScriptData(TYPE_SCRIPT_CONTENTS, GURL(), utf16);
26 // static
27 scoped_refptr<ProxyResolverScriptData> ProxyResolverScriptData::FromURL(
28 const GURL& url) {
29 return new ProxyResolverScriptData(TYPE_SCRIPT_URL, url, string16());
32 // static
33 scoped_refptr<ProxyResolverScriptData>
34 ProxyResolverScriptData::ForAutoDetect() {
35 return new ProxyResolverScriptData(TYPE_AUTO_DETECT, GURL(), string16());
38 const string16& ProxyResolverScriptData::utf16() const {
39 DCHECK_EQ(TYPE_SCRIPT_CONTENTS, type_);
40 return utf16_;
43 const GURL& ProxyResolverScriptData::url() const {
44 DCHECK_EQ(TYPE_SCRIPT_URL, type_);
45 return url_;
48 bool ProxyResolverScriptData::Equals(
49 const ProxyResolverScriptData* other) const {
50 if (type() != other->type())
51 return false;
53 switch (type()) {
54 case TYPE_SCRIPT_CONTENTS:
55 return utf16() == other->utf16();
56 case TYPE_SCRIPT_URL:
57 return url() == other->url();
58 case TYPE_AUTO_DETECT:
59 return true;
62 return false; // Shouldn't be reached.
65 ProxyResolverScriptData::ProxyResolverScriptData(Type type,
66 const GURL& url,
67 const string16& utf16)
68 : type_(type),
69 url_(url),
70 utf16_(utf16) {
73 ProxyResolverScriptData::~ProxyResolverScriptData() {}
75 } // namespace net