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

Side by Side Diff: net/base/network_change_notifier_linux.cc

Issue 11360108: Start calculating new combined NetworkChangeNotifier signal (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Switch to default argument constructor Created 8 years 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/base/network_change_notifier_linux.h ('k') | net/base/network_change_notifier_mac.h » ('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 "net/base/network_change_notifier_linux.h" 5 #include "net/base/network_change_notifier_linux.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "net/base/address_tracker_linux.h" 10 #include "net/base/address_tracker_linux.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 void NetworkChangeNotifierLinux::Thread::CleanUp() { 63 void NetworkChangeNotifierLinux::Thread::CleanUp() {
64 dns_config_service_.reset(); 64 dns_config_service_.reset();
65 } 65 }
66 66
67 NetworkChangeNotifierLinux* NetworkChangeNotifierLinux::Create() { 67 NetworkChangeNotifierLinux* NetworkChangeNotifierLinux::Create() {
68 return new NetworkChangeNotifierLinux(); 68 return new NetworkChangeNotifierLinux();
69 } 69 }
70 70
71 NetworkChangeNotifierLinux::NetworkChangeNotifierLinux() 71 NetworkChangeNotifierLinux::NetworkChangeNotifierLinux()
72 : notifier_thread_(new Thread()) { 72 : NetworkChangeNotifier(NetworkChangeCalculatorParamsLinux()),
73 notifier_thread_(new Thread()) {
73 // We create this notifier thread because the notification implementation 74 // We create this notifier thread because the notification implementation
74 // needs a MessageLoopForIO, and there's no guarantee that 75 // needs a MessageLoopForIO, and there's no guarantee that
75 // MessageLoop::current() meets that criterion. 76 // MessageLoop::current() meets that criterion.
76 base::Thread::Options thread_options(MessageLoop::TYPE_IO, 0); 77 base::Thread::Options thread_options(MessageLoop::TYPE_IO, 0);
77 notifier_thread_->StartWithOptions(thread_options); 78 notifier_thread_->StartWithOptions(thread_options);
78 } 79 }
79 80
80 NetworkChangeNotifierLinux::~NetworkChangeNotifierLinux() { 81 NetworkChangeNotifierLinux::~NetworkChangeNotifierLinux() {
81 // Stopping from here allows us to sanity- check that the notifier 82 // Stopping from here allows us to sanity- check that the notifier
82 // thread shut down properly. 83 // thread shut down properly.
83 notifier_thread_->Stop(); 84 notifier_thread_->Stop();
84 } 85 }
85 86
87 // static
88 NetworkChangeNotifier::NetworkChangeCalculatorParams
89 NetworkChangeNotifierLinux::NetworkChangeCalculatorParamsLinux() {
90 NetworkChangeCalculatorParams params;
91 // Delay values arrived at by simple experimentation and adjusted so as to
92 // produce a single signal when switching between network connections.
93 params.ip_address_offline_delay_ = base::TimeDelta::FromMilliseconds(2000);
94 params.ip_address_online_delay_ = base::TimeDelta::FromMilliseconds(2000);
95 params.connection_type_offline_delay_ =
96 base::TimeDelta::FromMilliseconds(1500);
97 params.connection_type_online_delay_ = base::TimeDelta::FromMilliseconds(500);
98 return params;
99 }
100
86 NetworkChangeNotifier::ConnectionType 101 NetworkChangeNotifier::ConnectionType
87 NetworkChangeNotifierLinux::GetCurrentConnectionType() const { 102 NetworkChangeNotifierLinux::GetCurrentConnectionType() const {
88 return notifier_thread_->GetCurrentConnectionType(); 103 return notifier_thread_->GetCurrentConnectionType();
89 } 104 }
90 105
91 const internal::AddressTrackerLinux* 106 const internal::AddressTrackerLinux*
92 NetworkChangeNotifierLinux::GetAddressTrackerInternal() const { 107 NetworkChangeNotifierLinux::GetAddressTrackerInternal() const {
93 return notifier_thread_->address_tracker(); 108 return notifier_thread_->address_tracker();
94 } 109 }
95 110
96 } // namespace net 111 } // namespace net
OLDNEW
« no previous file with comments | « net/base/network_change_notifier_linux.h ('k') | net/base/network_change_notifier_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698