summaryrefslogtreecommitdiffstats
path: root/net/android
diff options
context:
space:
mode:
authorttuttle@chromium.org <ttuttle@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-21 20:31:14 +0000
committerttuttle@chromium.org <ttuttle@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-21 20:31:14 +0000
commitf667903d802f93956d4efcc30be5f4e30ce294f9 (patch)
tree4bbbe2b59c499173e368331b6ce87b76d888c13e /net/android
parentcf2a970c2c65f8111f3015d640118e1fb98dc485 (diff)
downloadchromium_src-f667903d802f93956d4efcc30be5f4e30ce294f9.zip
chromium_src-f667903d802f93956d4efcc30be5f4e30ce294f9.tar.gz
chromium_src-f667903d802f93956d4efcc30be5f4e30ce294f9.tar.bz2
Add Android support in DnsConfigServicePosix.
Add support for Android in DnsConfigServicePosix by: 1. Adding ReadDnsConfig that reads the net.dns[12] system properties. 2. Adding ConfigWatcher that triggers on network change events. 3. Pointing HostsWatcher at /system/etc/hosts. BUG=149752,334794 Review URL: https://codereview.chromium.org/138623003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246101 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/android')
-rw-r--r--net/android/network_change_notifier_android.cc36
-rw-r--r--net/android/network_change_notifier_android.h3
2 files changed, 38 insertions, 1 deletions
diff --git a/net/android/network_change_notifier_android.cc b/net/android/network_change_notifier_android.cc
index d4e1a5c..e0f5244 100644
--- a/net/android/network_change_notifier_android.cc
+++ b/net/android/network_change_notifier_android.cc
@@ -59,8 +59,39 @@
#include "net/android/network_change_notifier_android.h"
+#include "base/threading/thread.h"
+#include "net/dns/dns_config_service.h"
+
namespace net {
+// Thread on which we can run DnsConfigService, which requires a TYPE_IO
+// message loop to monitor /system/etc/hosts.
+class NetworkChangeNotifierAndroid::DnsConfigServiceThread
+ : public base::Thread {
+ public:
+ DnsConfigServiceThread() : base::Thread("DnsConfigService") {}
+
+ virtual ~DnsConfigServiceThread() {
+ Stop();
+ }
+
+ virtual void Init() OVERRIDE {
+ dns_config_service_ = DnsConfigService::CreateSystemService();
+ dns_config_service_->WatchConfig(
+ base::Bind(&NetworkChangeNotifier::SetDnsConfig));
+ }
+
+ virtual void CleanUp() OVERRIDE {
+ dns_config_service_.reset();
+ }
+
+ private:
+ scoped_ptr<DnsConfigService> dns_config_service_;
+
+ DISALLOW_COPY_AND_ASSIGN(DnsConfigServiceThread);
+};
+
+
NetworkChangeNotifierAndroid::~NetworkChangeNotifierAndroid() {
delegate_->RemoveObserver(this);
}
@@ -83,8 +114,11 @@ bool NetworkChangeNotifierAndroid::Register(JNIEnv* env) {
NetworkChangeNotifierAndroid::NetworkChangeNotifierAndroid(
NetworkChangeNotifierDelegateAndroid* delegate)
: NetworkChangeNotifier(NetworkChangeCalculatorParamsAndroid()),
- delegate_(delegate) {
+ delegate_(delegate),
+ dns_config_service_thread_(new DnsConfigServiceThread()) {
delegate_->AddObserver(this);
+ dns_config_service_thread_->StartWithOptions(
+ base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
}
// static
diff --git a/net/android/network_change_notifier_android.h b/net/android/network_change_notifier_android.h
index f167cfc..e82b852 100644
--- a/net/android/network_change_notifier_android.h
+++ b/net/android/network_change_notifier_android.h
@@ -56,12 +56,15 @@ class NET_EXPORT_PRIVATE NetworkChangeNotifierAndroid
friend class NetworkChangeNotifierAndroidTest;
friend class NetworkChangeNotifierFactoryAndroid;
+ class DnsConfigServiceThread;
+
explicit NetworkChangeNotifierAndroid(
NetworkChangeNotifierDelegateAndroid* delegate);
static NetworkChangeCalculatorParams NetworkChangeCalculatorParamsAndroid();
NetworkChangeNotifierDelegateAndroid* const delegate_;
+ scoped_ptr<DnsConfigServiceThread> dns_config_service_thread_;
DISALLOW_COPY_AND_ASSIGN(NetworkChangeNotifierAndroid);
};