OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "net/proxy/proxy_resolver_script_data.h" | 5 #include "net/proxy/proxy_resolver_script_data.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
11 | 11 |
12 // static | 12 // static |
13 scoped_refptr<ProxyResolverScriptData> ProxyResolverScriptData::FromUTF8( | 13 scoped_refptr<ProxyResolverScriptData> ProxyResolverScriptData::FromUTF8( |
14 const std::string& utf8) { | 14 const std::string& utf8) { |
15 return new ProxyResolverScriptData(TYPE_SCRIPT_CONTENTS, | 15 return new ProxyResolverScriptData( |
16 GURL(), | 16 TYPE_SCRIPT_CONTENTS, GURL(), base::UTF8ToUTF16(utf8)); |
17 base::UTF8ToUTF16(utf8)); | |
18 } | 17 } |
19 | 18 |
20 // static | 19 // static |
21 scoped_refptr<ProxyResolverScriptData> ProxyResolverScriptData::FromUTF16( | 20 scoped_refptr<ProxyResolverScriptData> ProxyResolverScriptData::FromUTF16( |
22 const base::string16& utf16) { | 21 const base::string16& utf16) { |
23 return new ProxyResolverScriptData(TYPE_SCRIPT_CONTENTS, GURL(), utf16); | 22 return new ProxyResolverScriptData(TYPE_SCRIPT_CONTENTS, GURL(), utf16); |
24 } | 23 } |
25 | 24 |
26 // static | 25 // static |
27 scoped_refptr<ProxyResolverScriptData> ProxyResolverScriptData::FromURL( | 26 scoped_refptr<ProxyResolverScriptData> ProxyResolverScriptData::FromURL( |
28 const GURL& url) { | 27 const GURL& url) { |
29 return new ProxyResolverScriptData(TYPE_SCRIPT_URL, url, base::string16()); | 28 return new ProxyResolverScriptData(TYPE_SCRIPT_URL, url, base::string16()); |
30 } | 29 } |
31 | 30 |
32 // static | 31 // static |
33 scoped_refptr<ProxyResolverScriptData> | 32 scoped_refptr<ProxyResolverScriptData> |
34 ProxyResolverScriptData::ForAutoDetect() { | 33 ProxyResolverScriptData::ForAutoDetect() { |
35 return new ProxyResolverScriptData(TYPE_AUTO_DETECT, GURL(), | 34 return new ProxyResolverScriptData( |
36 base::string16()); | 35 TYPE_AUTO_DETECT, GURL(), base::string16()); |
37 } | 36 } |
38 | 37 |
39 const base::string16& ProxyResolverScriptData::utf16() const { | 38 const base::string16& ProxyResolverScriptData::utf16() const { |
40 DCHECK_EQ(TYPE_SCRIPT_CONTENTS, type_); | 39 DCHECK_EQ(TYPE_SCRIPT_CONTENTS, type_); |
41 return utf16_; | 40 return utf16_; |
42 } | 41 } |
43 | 42 |
44 const GURL& ProxyResolverScriptData::url() const { | 43 const GURL& ProxyResolverScriptData::url() const { |
45 DCHECK_EQ(TYPE_SCRIPT_URL, type_); | 44 DCHECK_EQ(TYPE_SCRIPT_URL, type_); |
46 return url_; | 45 return url_; |
(...skipping 12 matching lines...) Expand all Loading... |
59 case TYPE_AUTO_DETECT: | 58 case TYPE_AUTO_DETECT: |
60 return true; | 59 return true; |
61 } | 60 } |
62 | 61 |
63 return false; // Shouldn't be reached. | 62 return false; // Shouldn't be reached. |
64 } | 63 } |
65 | 64 |
66 ProxyResolverScriptData::ProxyResolverScriptData(Type type, | 65 ProxyResolverScriptData::ProxyResolverScriptData(Type type, |
67 const GURL& url, | 66 const GURL& url, |
68 const base::string16& utf16) | 67 const base::string16& utf16) |
69 : type_(type), | 68 : type_(type), url_(url), utf16_(utf16) { |
70 url_(url), | |
71 utf16_(utf16) { | |
72 } | 69 } |
73 | 70 |
74 ProxyResolverScriptData::~ProxyResolverScriptData() {} | 71 ProxyResolverScriptData::~ProxyResolverScriptData() { |
| 72 } |
75 | 73 |
76 } // namespace net | 74 } // namespace net |
OLD | NEW |