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

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

Issue 2090613002: Remove calls to deprecated MessageLoop methods in net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | net/disk_cache/disk_cache_test_util.cc » ('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_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"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/single_thread_task_runner.h"
14 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
15 #include "base/threading/thread_restrictions.h" 16 #include "base/threading/thread_restrictions.h"
16 17
17 namespace net { 18 namespace net {
18 19
19 namespace { 20 namespace {
20 21
21 #if !defined(OS_IOS) 22 #if !defined(OS_IOS)
22 // Called back by OS. Calls OnNetworkConfigChange(). 23 // Called back by OS. Calls OnNetworkConfigChange().
23 void DynamicStoreCallback(SCDynamicStoreRef /* store */, 24 void DynamicStoreCallback(SCDynamicStoreRef /* store */,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 void NetworkConfigWatcherMacThread::Init() { 69 void NetworkConfigWatcherMacThread::Init() {
69 // Disallow IO to make sure NetworkConfigWatcherMacThread's helper thread does 70 // Disallow IO to make sure NetworkConfigWatcherMacThread's helper thread does
70 // not perform blocking operations. 71 // not perform blocking operations.
71 base::ThreadRestrictions::SetIOAllowed(false); 72 base::ThreadRestrictions::SetIOAllowed(false);
72 73
73 delegate_->Init(); 74 delegate_->Init();
74 75
75 // TODO(willchan): Look to see if there's a better signal for when it's ok to 76 // TODO(willchan): Look to see if there's a better signal for when it's ok to
76 // initialize this, rather than just delaying it by a fixed time. 77 // initialize this, rather than just delaying it by a fixed time.
77 const base::TimeDelta kInitializationDelay = base::TimeDelta::FromSeconds(1); 78 const base::TimeDelta kInitializationDelay = base::TimeDelta::FromSeconds(1);
78 message_loop()->PostDelayedTask( 79 task_runner()->PostDelayedTask(
79 FROM_HERE, 80 FROM_HERE, base::Bind(&NetworkConfigWatcherMacThread::InitNotifications,
80 base::Bind(&NetworkConfigWatcherMacThread::InitNotifications, 81 weak_factory_.GetWeakPtr()),
81 weak_factory_.GetWeakPtr()),
82 kInitializationDelay); 82 kInitializationDelay);
83 } 83 }
84 84
85 void NetworkConfigWatcherMacThread::CleanUp() { 85 void NetworkConfigWatcherMacThread::CleanUp() {
86 if (!run_loop_source_.get()) 86 if (!run_loop_source_.get())
87 return; 87 return;
88 88
89 CFRunLoopRemoveSource(CFRunLoopGetCurrent(), run_loop_source_.get(), 89 CFRunLoopRemoveSource(CFRunLoopGetCurrent(), run_loop_source_.get(),
90 kCFRunLoopCommonModes); 90 kCFRunLoopCommonModes);
91 run_loop_source_.reset(); 91 run_loop_source_.reset();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // We create this notifier thread because the notification implementation 124 // We create this notifier thread because the notification implementation
125 // needs a thread with a CFRunLoop, and there's no guarantee that 125 // needs a thread with a CFRunLoop, and there's no guarantee that
126 // MessageLoop::current() meets that criterion. 126 // MessageLoop::current() meets that criterion.
127 base::Thread::Options thread_options(base::MessageLoop::TYPE_UI, 0); 127 base::Thread::Options thread_options(base::MessageLoop::TYPE_UI, 0);
128 notifier_thread_->StartWithOptions(thread_options); 128 notifier_thread_->StartWithOptions(thread_options);
129 } 129 }
130 130
131 NetworkConfigWatcherMac::~NetworkConfigWatcherMac() {} 131 NetworkConfigWatcherMac::~NetworkConfigWatcherMac() {}
132 132
133 } // namespace net 133 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/disk_cache_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698