| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 const int num_chars = base::RandInt(7, 15); | 84 const int num_chars = base::RandInt(7, 15); |
| 85 for (int j = 0; j < num_chars; ++j) | 85 for (int j = 0; j < num_chars; ++j) |
| 86 url_string += ('a' + base::RandInt(0, 'z' - 'a')); | 86 url_string += ('a' + base::RandInt(0, 'z' - 'a')); |
| 87 GURL random_url(url_string + '/'); | 87 GURL random_url(url_string + '/'); |
| 88 net::URLFetcher* fetcher = | 88 net::URLFetcher* fetcher = |
| 89 net::URLFetcher::Create(random_url, net::URLFetcher::HEAD, this) | 89 net::URLFetcher::Create(random_url, net::URLFetcher::HEAD, this) |
| 90 .release(); | 90 .release(); |
| 91 // We don't want these fetches to affect existing state in the profile. | 91 // We don't want these fetches to affect existing state in the profile. |
| 92 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE | | 92 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE | |
| 93 net::LOAD_DO_NOT_SAVE_COOKIES | | 93 net::LOAD_DO_NOT_SAVE_COOKIES | |
| 94 net::LOAD_DO_NOT_SEND_COOKIES); | 94 net::LOAD_DO_NOT_SEND_COOKIES | |
| 95 net::LOAD_DO_NOT_SEND_AUTH_DATA); |
| 95 fetcher->SetRequestContext(g_browser_process->system_request_context()); | 96 fetcher->SetRequestContext(g_browser_process->system_request_context()); |
| 96 fetcher->Start(); | 97 fetcher->Start(); |
| 97 fetchers_.insert(fetcher); | 98 fetchers_.insert(fetcher); |
| 98 } | 99 } |
| 99 } | 100 } |
| 100 | 101 |
| 101 void IntranetRedirectDetector::OnURLFetchComplete( | 102 void IntranetRedirectDetector::OnURLFetchComplete( |
| 102 const net::URLFetcher* source) { | 103 const net::URLFetcher* source) { |
| 103 // Delete the fetcher on this function's exit. | 104 // Delete the fetcher on this function's exit. |
| 104 Fetchers::iterator fetcher = fetchers_.find( | 105 Fetchers::iterator fetcher = fetchers_.find( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 162 |
| 162 // Since presumably many programs open connections after network changes, | 163 // Since presumably many programs open connections after network changes, |
| 163 // delay this a little bit. | 164 // delay this a little bit. |
| 164 in_sleep_ = true; | 165 in_sleep_ = true; |
| 165 static const int kNetworkSwitchDelayMS = 1000; | 166 static const int kNetworkSwitchDelayMS = 1000; |
| 166 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 167 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 167 FROM_HERE, base::Bind(&IntranetRedirectDetector::FinishSleep, | 168 FROM_HERE, base::Bind(&IntranetRedirectDetector::FinishSleep, |
| 168 weak_ptr_factory_.GetWeakPtr()), | 169 weak_ptr_factory_.GetWeakPtr()), |
| 169 base::TimeDelta::FromMilliseconds(kNetworkSwitchDelayMS)); | 170 base::TimeDelta::FromMilliseconds(kNetworkSwitchDelayMS)); |
| 170 } | 171 } |
| OLD | NEW |