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

Side by Side Diff: chrome/browser/chromeos/net/chrome_network_watcher.cc

Issue 238433003: Provide Shill IP Address to myIpAddress() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Non proxy specific implementation Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/net/chrome_network_watcher.h"
6
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/io_thread.h"
11 #include "chromeos/network/network_handler.h"
12 #include "chromeos/network/network_state.h"
13 #include "chromeos/network/network_state_handler.h"
14 #include "content/public/browser/browser_thread.h"
15
16 namespace chromeos {
17
18 namespace {
19
20 void SetIPAddress(const std::string& ip_address) {
21 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
22 g_browser_process->io_thread()->globals()->host_resolver->set_my_ip_address(
23 ip_address);
24 }
25
26 }
27
28 ChromeNetworkWatcher::ChromeNetworkWatcher() {
29 NetworkHandler::Get()->network_state_handler()->AddObserver(this, FROM_HERE);
30 DefaultNetworkChanged(
31 NetworkHandler::Get()->network_state_handler()->DefaultNetwork());
32 }
33
34 ChromeNetworkWatcher::~ChromeNetworkWatcher() {
35 NetworkHandler::Get()->network_state_handler()->RemoveObserver(this,
36 FROM_HERE);
37 }
38
39 void ChromeNetworkWatcher::DefaultNetworkChanged(const NetworkState* network) {
40 std::string ip_address = network ? network->ip_address() : "";
41 if (ip_address == last_ip_address_)
42 return;
43 last_ip_address_ = ip_address;
44 content::BrowserThread::PostTask(content::BrowserThread::IO,
45 FROM_HERE,
46 base::Bind(&SetIPAddress, ip_address));
47 }
48
49 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698