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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 65 |
66 Stop(); | 66 Stop(); |
67 } | 67 } |
68 | 68 |
69 void NetworkConfigWatcherMacThread::Init() { | 69 void NetworkConfigWatcherMacThread::Init() { |
70 // Disallow IO to make sure NetworkConfigWatcherMacThread's helper thread does | 70 base::ThreadRestrictions::SetIOAllowed(true); |
71 // not perform blocking operations. | |
72 base::ThreadRestrictions::SetIOAllowed(false); | |
73 | |
74 delegate_->Init(); | 71 delegate_->Init(); |
75 | 72 |
76 // TODO(willchan): Look to see if there's a better signal for when it's ok to | 73 // 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. | 74 // initialize this, rather than just delaying it by a fixed time. |
78 const base::TimeDelta kInitializationDelay = base::TimeDelta::FromSeconds(1); | 75 const base::TimeDelta kInitializationDelay = base::TimeDelta::FromSeconds(1); |
79 task_runner()->PostDelayedTask( | 76 task_runner()->PostDelayedTask( |
80 FROM_HERE, base::Bind(&NetworkConfigWatcherMacThread::InitNotifications, | 77 FROM_HERE, base::Bind(&NetworkConfigWatcherMacThread::InitNotifications, |
81 weak_factory_.GetWeakPtr()), | 78 weak_factory_.GetWeakPtr()), |
82 kInitializationDelay); | 79 kInitializationDelay); |
83 } | 80 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // We create this notifier thread because the notification implementation | 121 // We create this notifier thread because the notification implementation |
125 // needs a thread with a CFRunLoop, and there's no guarantee that | 122 // needs a thread with a CFRunLoop, and there's no guarantee that |
126 // MessageLoop::current() meets that criterion. | 123 // MessageLoop::current() meets that criterion. |
127 base::Thread::Options thread_options(base::MessageLoop::TYPE_UI, 0); | 124 base::Thread::Options thread_options(base::MessageLoop::TYPE_UI, 0); |
128 notifier_thread_->StartWithOptions(thread_options); | 125 notifier_thread_->StartWithOptions(thread_options); |
129 } | 126 } |
130 | 127 |
131 NetworkConfigWatcherMac::~NetworkConfigWatcherMac() {} | 128 NetworkConfigWatcherMac::~NetworkConfigWatcherMac() {} |
132 | 129 |
133 } // namespace net | 130 } // namespace net |
OLD | NEW |