Chromium Code Reviews| 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 "net/base/network_config_watcher_mac.h" | 5 #include "net/base/network_config_watcher_mac.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 NetworkConfigWatcherMacThread::NetworkConfigWatcherMacThread( | 55 NetworkConfigWatcherMacThread::NetworkConfigWatcherMacThread( |
| 56 NetworkConfigWatcherMac::Delegate* delegate) | 56 NetworkConfigWatcherMac::Delegate* delegate) |
| 57 : base::Thread("NetworkConfigWatcher"), | 57 : base::Thread("NetworkConfigWatcher"), |
| 58 delegate_(delegate), | 58 delegate_(delegate), |
| 59 weak_factory_(this) {} | 59 weak_factory_(this) {} |
| 60 | 60 |
| 61 NetworkConfigWatcherMacThread::~NetworkConfigWatcherMacThread() { | 61 NetworkConfigWatcherMacThread::~NetworkConfigWatcherMacThread() { |
| 62 // Allow IO because Stop() calls PlatformThread::Join(), which is a blocking | 62 // Allow IO because Stop() calls PlatformThread::Join(), which is a blocking |
| 63 // operation. This is expected during shutdown. | 63 // operation. This is expected during shutdown. |
| 64 base::ThreadRestrictions::ScopedAllowIO allow_io; | 64 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 65 | |
|
pauljensen
2017/05/31 14:52:38
needless whitespace change
jkarlin
2017/05/31 15:11:55
Done.
| |
| 66 Stop(); | 65 Stop(); |
| 67 } | 66 } |
| 68 | 67 |
| 69 void NetworkConfigWatcherMacThread::Init() { | 68 void NetworkConfigWatcherMacThread::Init() { |
| 70 // Disallow IO to make sure NetworkConfigWatcherMacThread's helper thread does | 69 base::ThreadRestrictions::SetIOAllowed(true); |
| 71 // not perform blocking operations. | |
| 72 base::ThreadRestrictions::SetIOAllowed(false); | |
| 73 | |
| 74 delegate_->Init(); | 70 delegate_->Init(); |
| 75 | 71 |
| 76 // TODO(willchan): Look to see if there's a better signal for when it's ok to | 72 // TODO(willchan): Look to see if there's a better signal for when it's ok to |
| 77 // initialize this, rather than just delaying it by a fixed time. | 73 // initialize this, rather than just delaying it by a fixed time. |
| 78 const base::TimeDelta kInitializationDelay = base::TimeDelta::FromSeconds(1); | 74 const base::TimeDelta kInitializationDelay = base::TimeDelta::FromSeconds(1); |
| 79 task_runner()->PostDelayedTask( | 75 task_runner()->PostDelayedTask( |
| 80 FROM_HERE, base::Bind(&NetworkConfigWatcherMacThread::InitNotifications, | 76 FROM_HERE, base::Bind(&NetworkConfigWatcherMacThread::InitNotifications, |
| 81 weak_factory_.GetWeakPtr()), | 77 weak_factory_.GetWeakPtr()), |
| 82 kInitializationDelay); | 78 kInitializationDelay); |
| 83 } | 79 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 // We create this notifier thread because the notification implementation | 120 // We create this notifier thread because the notification implementation |
| 125 // needs a thread with a CFRunLoop, and there's no guarantee that | 121 // needs a thread with a CFRunLoop, and there's no guarantee that |
| 126 // MessageLoop::current() meets that criterion. | 122 // MessageLoop::current() meets that criterion. |
| 127 base::Thread::Options thread_options(base::MessageLoop::TYPE_UI, 0); | 123 base::Thread::Options thread_options(base::MessageLoop::TYPE_UI, 0); |
| 128 notifier_thread_->StartWithOptions(thread_options); | 124 notifier_thread_->StartWithOptions(thread_options); |
| 129 } | 125 } |
| 130 | 126 |
| 131 NetworkConfigWatcherMac::~NetworkConfigWatcherMac() {} | 127 NetworkConfigWatcherMac::~NetworkConfigWatcherMac() {} |
| 132 | 128 |
| 133 } // namespace net | 129 } // namespace net |
| OLD | NEW |