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

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

Issue 2230203002: chrome: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed accidental components/ change Created 4 years, 4 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
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 <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 30 matching lines...) Expand all
41 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 41 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
42 FROM_HERE, base::Bind(&IntranetRedirectDetector::FinishSleep, 42 FROM_HERE, base::Bind(&IntranetRedirectDetector::FinishSleep,
43 weak_ptr_factory_.GetWeakPtr()), 43 weak_ptr_factory_.GetWeakPtr()),
44 base::TimeDelta::FromSeconds(kStartFetchDelaySeconds)); 44 base::TimeDelta::FromSeconds(kStartFetchDelaySeconds));
45 45
46 net::NetworkChangeNotifier::AddIPAddressObserver(this); 46 net::NetworkChangeNotifier::AddIPAddressObserver(this);
47 } 47 }
48 48
49 IntranetRedirectDetector::~IntranetRedirectDetector() { 49 IntranetRedirectDetector::~IntranetRedirectDetector() {
50 net::NetworkChangeNotifier::RemoveIPAddressObserver(this); 50 net::NetworkChangeNotifier::RemoveIPAddressObserver(this);
51 STLDeleteElements(&fetchers_); 51 base::STLDeleteElements(&fetchers_);
52 } 52 }
53 53
54 // static 54 // static
55 GURL IntranetRedirectDetector::RedirectOrigin() { 55 GURL IntranetRedirectDetector::RedirectOrigin() {
56 const IntranetRedirectDetector* const detector = 56 const IntranetRedirectDetector* const detector =
57 g_browser_process->intranet_redirect_detector(); 57 g_browser_process->intranet_redirect_detector();
58 return detector ? detector->redirect_origin_ : GURL(); 58 return detector ? detector->redirect_origin_ : GURL();
59 } 59 }
60 60
61 // static 61 // static
62 void IntranetRedirectDetector::RegisterPrefs(PrefRegistrySimple* registry) { 62 void IntranetRedirectDetector::RegisterPrefs(PrefRegistrySimple* registry) {
63 registry->RegisterStringPref(prefs::kLastKnownIntranetRedirectOrigin, 63 registry->RegisterStringPref(prefs::kLastKnownIntranetRedirectOrigin,
64 std::string()); 64 std::string());
65 } 65 }
66 66
67 void IntranetRedirectDetector::FinishSleep() { 67 void IntranetRedirectDetector::FinishSleep() {
68 in_sleep_ = false; 68 in_sleep_ = false;
69 69
70 // If another fetch operation is still running, cancel it. 70 // If another fetch operation is still running, cancel it.
71 STLDeleteElements(&fetchers_); 71 base::STLDeleteElements(&fetchers_);
72 resulting_origins_.clear(); 72 resulting_origins_.clear();
73 73
74 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 74 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
75 if (cmd_line->HasSwitch(switches::kDisableBackgroundNetworking)) 75 if (cmd_line->HasSwitch(switches::kDisableBackgroundNetworking))
76 return; 76 return;
77 77
78 DCHECK(fetchers_.empty() && resulting_origins_.empty()); 78 DCHECK(fetchers_.empty() && resulting_origins_.empty());
79 79
80 // Start three fetchers on random hostnames. 80 // Start three fetchers on random hostnames.
81 for (size_t i = 0; i < 3; ++i) { 81 for (size_t i = 0; i < 3; ++i) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 162
163 // Since presumably many programs open connections after network changes, 163 // Since presumably many programs open connections after network changes,
164 // delay this a little bit. 164 // delay this a little bit.
165 in_sleep_ = true; 165 in_sleep_ = true;
166 static const int kNetworkSwitchDelayMS = 1000; 166 static const int kNetworkSwitchDelayMS = 1000;
167 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 167 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
168 FROM_HERE, base::Bind(&IntranetRedirectDetector::FinishSleep, 168 FROM_HERE, base::Bind(&IntranetRedirectDetector::FinishSleep,
169 weak_ptr_factory_.GetWeakPtr()), 169 weak_ptr_factory_.GetWeakPtr()),
170 base::TimeDelta::FromMilliseconds(kNetworkSwitchDelayMS)); 170 base::TimeDelta::FromMilliseconds(kNetworkSwitchDelayMS));
171 } 171 }
OLDNEW
« no previous file with comments | « chrome/browser/importer/ie_importer_browsertest_win.cc ('k') | chrome/browser/io_thread_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698