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

Side by Side Diff: chrome/browser/intranet_redirect_detector.cc

Issue 10554008: Move content::URLFetcher static functions to net::URLFetcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix win link error Created 8 years, 6 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 | « chrome/browser/intents/cws_intents_registry.cc ('k') | chrome/browser/io_thread.cc » ('j') | 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 "chrome/browser/intranet_redirect_detector.h" 5 #include "chrome/browser/intranet_redirect_detector.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
16 #include "content/public/common/url_fetcher.h"
17 #include "net/base/load_flags.h" 16 #include "net/base/load_flags.h"
18 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
19 #include "net/base/registry_controlled_domain.h" 18 #include "net/base/registry_controlled_domain.h"
19 #include "net/url_request/url_fetcher.h"
20 #include "net/url_request/url_request_context_getter.h" 20 #include "net/url_request/url_request_context_getter.h"
21 #include "net/url_request/url_request_status.h" 21 #include "net/url_request/url_request_status.h"
22 22
23 const size_t IntranetRedirectDetector::kNumCharsInHostnames = 10; 23 const size_t IntranetRedirectDetector::kNumCharsInHostnames = 10;
24 24
25 IntranetRedirectDetector::IntranetRedirectDetector() 25 IntranetRedirectDetector::IntranetRedirectDetector()
26 : redirect_origin_(g_browser_process->local_state()->GetString( 26 : redirect_origin_(g_browser_process->local_state()->GetString(
27 prefs::kLastKnownIntranetRedirectOrigin)), 27 prefs::kLastKnownIntranetRedirectOrigin)),
28 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), 28 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
29 in_sleep_(true) { 29 in_sleep_(true) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 return; 74 return;
75 75
76 DCHECK(fetchers_.empty() && resulting_origins_.empty()); 76 DCHECK(fetchers_.empty() && resulting_origins_.empty());
77 77
78 // Start three fetchers on random hostnames. 78 // Start three fetchers on random hostnames.
79 for (size_t i = 0; i < 3; ++i) { 79 for (size_t i = 0; i < 3; ++i) {
80 std::string url_string("http://"); 80 std::string url_string("http://");
81 for (size_t j = 0; j < kNumCharsInHostnames; ++j) 81 for (size_t j = 0; j < kNumCharsInHostnames; ++j)
82 url_string += ('a' + base::RandInt(0, 'z' - 'a')); 82 url_string += ('a' + base::RandInt(0, 'z' - 'a'));
83 GURL random_url(url_string + '/'); 83 GURL random_url(url_string + '/');
84 net::URLFetcher* fetcher = content::URLFetcher::Create( 84 net::URLFetcher* fetcher = net::URLFetcher::Create(
85 random_url, net::URLFetcher::HEAD, this); 85 random_url, net::URLFetcher::HEAD, this);
86 // We don't want these fetches to affect existing state in the profile. 86 // We don't want these fetches to affect existing state in the profile.
87 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE | 87 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE |
88 net::LOAD_DO_NOT_SAVE_COOKIES | 88 net::LOAD_DO_NOT_SAVE_COOKIES |
89 net::LOAD_DO_NOT_SEND_COOKIES); 89 net::LOAD_DO_NOT_SEND_COOKIES);
90 fetcher->SetRequestContext(g_browser_process->system_request_context()); 90 fetcher->SetRequestContext(g_browser_process->system_request_context());
91 fetcher->Start(); 91 fetcher->Start();
92 fetchers_.insert(fetcher); 92 fetchers_.insert(fetcher);
93 } 93 }
94 } 94 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // the same thread. So just use the heuristic that any all-lowercase a-z 173 // the same thread. So just use the heuristic that any all-lowercase a-z
174 // hostname with the right number of characters is likely from the detector 174 // hostname with the right number of characters is likely from the detector
175 // (and thus should be blocked). 175 // (and thus should be blocked).
176 return ((host.length() == IntranetRedirectDetector::kNumCharsInHostnames) && 176 return ((host.length() == IntranetRedirectDetector::kNumCharsInHostnames) &&
177 (host.find_first_not_of("abcdefghijklmnopqrstuvwxyz") == 177 (host.find_first_not_of("abcdefghijklmnopqrstuvwxyz") ==
178 std::string::npos)) ? 178 std::string::npos)) ?
179 net::ERR_NAME_NOT_RESOLVED : 179 net::ERR_NAME_NOT_RESOLVED :
180 ResolveUsingPrevious(host, address_family, host_resolver_flags, addrlist, 180 ResolveUsingPrevious(host, address_family, host_resolver_flags, addrlist,
181 os_error); 181 os_error);
182 } 182 }
OLDNEW
« no previous file with comments | « chrome/browser/intents/cws_intents_registry.cc ('k') | chrome/browser/io_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698