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

Side by Side Diff: content/browser/background_sync/background_sync_network_observer.cc

Issue 1170623003: Revert "content: Remove use of MessageLoopProxy and deprecated MessageLoop APIs" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/browser/background_sync/background_sync_network_observer.h" 5 #include "content/browser/background_sync/background_sync_network_observer.h"
6 6
7 #include "base/location.h"
8 #include "base/single_thread_task_runner.h"
9 #include "base/thread_task_runner_handle.h"
10 #include "content/public/browser/browser_thread.h" 7 #include "content/public/browser/browser_thread.h"
11 8
12 namespace content { 9 namespace content {
13 10
14 BackgroundSyncNetworkObserver::BackgroundSyncNetworkObserver( 11 BackgroundSyncNetworkObserver::BackgroundSyncNetworkObserver(
15 const base::Closure& network_changed_callback) 12 const base::Closure& network_changed_callback)
16 : connection_type_(net::NetworkChangeNotifier::GetConnectionType()), 13 : connection_type_(net::NetworkChangeNotifier::GetConnectionType()),
17 network_changed_callback_(network_changed_callback) { 14 network_changed_callback_(network_changed_callback) {
18 DCHECK_CURRENTLY_ON(BrowserThread::IO); 15 DCHECK_CURRENTLY_ON(BrowserThread::IO);
19 16
(...skipping 23 matching lines...) Expand all
43 return connection_type_ != net::NetworkChangeNotifier::CONNECTION_NONE; 40 return connection_type_ != net::NetworkChangeNotifier::CONNECTION_NONE;
44 } 41 }
45 42
46 NOTREACHED(); 43 NOTREACHED();
47 return false; 44 return false;
48 } 45 }
49 46
50 void BackgroundSyncNetworkObserver::NotifyNetworkChanged() { 47 void BackgroundSyncNetworkObserver::NotifyNetworkChanged() {
51 DCHECK_CURRENTLY_ON(BrowserThread::IO); 48 DCHECK_CURRENTLY_ON(BrowserThread::IO);
52 49
53 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 50 base::MessageLoop::current()->PostTask(FROM_HERE, network_changed_callback_);
54 network_changed_callback_);
55 } 51 }
56 52
57 void BackgroundSyncNetworkObserver::OnNetworkChanged( 53 void BackgroundSyncNetworkObserver::OnNetworkChanged(
58 net::NetworkChangeNotifier::ConnectionType connection_type) { 54 net::NetworkChangeNotifier::ConnectionType connection_type) {
59 DCHECK_CURRENTLY_ON(BrowserThread::IO); 55 DCHECK_CURRENTLY_ON(BrowserThread::IO);
60 56
61 if (connection_type == connection_type_) 57 if (connection_type == connection_type_)
62 return; 58 return;
63 59
64 connection_type_ = connection_type; 60 connection_type_ = connection_type;
65 NotifyNetworkChanged(); 61 NotifyNetworkChanged();
66 } 62 }
67 63
68 } // namespace content 64 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/background_sync/background_sync_manager_unittest.cc ('k') | content/browser/browser_main_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698