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

Side by Side Diff: net/proxy/proxy_script_fetcher_impl.cc

Issue 266053002: Implement alternative string conversion functions in net/ on Android, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove GN changes Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « net/net.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_script_fetcher_impl.h" 5 #include "net/proxy/proxy_script_fetcher_impl.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/i18n/icu_string_conversions.h"
9 #include "base/logging.h" 8 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
11 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
12 #include "net/base/data_url.h" 11 #include "net/base/data_url.h"
13 #include "net/base/io_buffer.h" 12 #include "net/base/io_buffer.h"
14 #include "net/base/load_flags.h" 13 #include "net/base/load_flags.h"
15 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
15 #include "net/base/net_string_util.h"
16 #include "net/base/request_priority.h" 16 #include "net/base/request_priority.h"
17 #include "net/cert/cert_status_flags.h" 17 #include "net/cert/cert_status_flags.h"
18 #include "net/http/http_response_headers.h" 18 #include "net/http/http_response_headers.h"
19 #include "net/url_request/url_request_context.h" 19 #include "net/url_request/url_request_context.h"
20 20
21 // TODO(eroman): 21 // TODO(eroman):
22 // - Support auth-prompts (http://crbug.com/77366) 22 // - Support auth-prompts (http://crbug.com/77366)
23 23
24 namespace net { 24 namespace net {
25 25
(...skipping 23 matching lines...) Expand all
49 // Converts |bytes| (which is encoded by |charset|) to UTF16, saving the resul 49 // Converts |bytes| (which is encoded by |charset|) to UTF16, saving the resul
50 // to |*utf16|. 50 // to |*utf16|.
51 // If |charset| is empty, then we don't know what it was and guess. 51 // If |charset| is empty, then we don't know what it was and guess.
52 void ConvertResponseToUTF16(const std::string& charset, 52 void ConvertResponseToUTF16(const std::string& charset,
53 const std::string& bytes, 53 const std::string& bytes,
54 base::string16* utf16) { 54 base::string16* utf16) {
55 const char* codepage; 55 const char* codepage;
56 56
57 if (charset.empty()) { 57 if (charset.empty()) {
58 // Assume ISO-8859-1 if no charset was specified. 58 // Assume ISO-8859-1 if no charset was specified.
59 codepage = base::kCodepageLatin1; 59 codepage = kCharsetLatin1;
60 } else { 60 } else {
61 // Otherwise trust the charset that was provided. 61 // Otherwise trust the charset that was provided.
62 codepage = charset.c_str(); 62 codepage = charset.c_str();
63 } 63 }
64 64
65 // We will be generous in the conversion -- if any characters lie 65 // Be generous in the conversion -- if any characters lie outside of |charset|
66 // outside of |charset| (i.e. invalid), then substitute them with 66 // (i.e. invalid), then substitute them with U+FFFD rather than failing.
67 // U+FFFD rather than failing. 67 ConvertToUTF16WithSubstitutions(bytes, codepage, utf16);
68 base::CodepageToUTF16(bytes, codepage,
69 base::OnStringConversionError::SUBSTITUTE,
70 utf16);
71 } 68 }
72 69
73 } // namespace 70 } // namespace
74 71
75 ProxyScriptFetcherImpl::ProxyScriptFetcherImpl( 72 ProxyScriptFetcherImpl::ProxyScriptFetcherImpl(
76 URLRequestContext* url_request_context) 73 URLRequestContext* url_request_context)
77 : weak_factory_(this), 74 : weak_factory_(this),
78 url_request_context_(url_request_context), 75 url_request_context_(url_request_context),
79 buf_(new IOBuffer(kBufSize)), 76 buf_(new IOBuffer(kBufSize)),
80 next_id_(0), 77 next_id_(0),
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 // is still applicable. 311 // is still applicable.
315 if (cur_request_id_ != id) 312 if (cur_request_id_ != id)
316 return; 313 return;
317 314
318 DCHECK(cur_request_.get()); 315 DCHECK(cur_request_.get());
319 result_code_ = ERR_TIMED_OUT; 316 result_code_ = ERR_TIMED_OUT;
320 cur_request_->Cancel(); 317 cur_request_->Cancel();
321 } 318 }
322 319
323 } // namespace net 320 } // namespace net
OLDNEW
« no previous file with comments | « net/net.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698