| 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 "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/prefs/pref_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 DCHECK(fetchers_.empty() && resulting_origins_.empty()); | 73 DCHECK(fetchers_.empty() && resulting_origins_.empty()); |
| 74 | 74 |
| 75 // Start three fetchers on random hostnames. | 75 // Start three fetchers on random hostnames. |
| 76 for (size_t i = 0; i < 3; ++i) { | 76 for (size_t i = 0; i < 3; ++i) { |
| 77 std::string url_string("http://"); | 77 std::string url_string("http://"); |
| 78 // We generate a random hostname with between 7 and 15 characters. | 78 // We generate a random hostname with between 7 and 15 characters. |
| 79 const int num_chars = base::RandInt(7, 15); | 79 const int num_chars = base::RandInt(7, 15); |
| 80 for (int j = 0; j < num_chars; ++j) | 80 for (int j = 0; j < num_chars; ++j) |
| 81 url_string += ('a' + base::RandInt(0, 'z' - 'a')); | 81 url_string += ('a' + base::RandInt(0, 'z' - 'a')); |
| 82 GURL random_url(url_string + '/'); | 82 GURL random_url(url_string + '/'); |
| 83 net::URLFetcher* fetcher = net::URLFetcher::Create( | 83 net::URLFetcher* fetcher = |
| 84 random_url, net::URLFetcher::HEAD, this); | 84 net::URLFetcher::Create(random_url, net::URLFetcher::HEAD, this) |
| 85 .release(); |
| 85 // 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. |
| 86 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE | | 87 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE | |
| 87 net::LOAD_DO_NOT_SAVE_COOKIES | | 88 net::LOAD_DO_NOT_SAVE_COOKIES | |
| 88 net::LOAD_DO_NOT_SEND_COOKIES); | 89 net::LOAD_DO_NOT_SEND_COOKIES); |
| 89 fetcher->SetRequestContext(g_browser_process->system_request_context()); | 90 fetcher->SetRequestContext(g_browser_process->system_request_context()); |
| 90 fetcher->Start(); | 91 fetcher->Start(); |
| 91 fetchers_.insert(fetcher); | 92 fetchers_.insert(fetcher); |
| 92 } | 93 } |
| 93 } | 94 } |
| 94 | 95 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 156 |
| 156 // Since presumably many programs open connections after network changes, | 157 // Since presumably many programs open connections after network changes, |
| 157 // delay this a little bit. | 158 // delay this a little bit. |
| 158 in_sleep_ = true; | 159 in_sleep_ = true; |
| 159 static const int kNetworkSwitchDelayMS = 1000; | 160 static const int kNetworkSwitchDelayMS = 1000; |
| 160 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, | 161 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 161 base::Bind(&IntranetRedirectDetector::FinishSleep, | 162 base::Bind(&IntranetRedirectDetector::FinishSleep, |
| 162 weak_ptr_factory_.GetWeakPtr()), | 163 weak_ptr_factory_.GetWeakPtr()), |
| 163 base::TimeDelta::FromMilliseconds(kNetworkSwitchDelayMS)); | 164 base::TimeDelta::FromMilliseconds(kNetworkSwitchDelayMS)); |
| 164 } | 165 } |
| OLD | NEW |