summaryrefslogtreecommitdiffstats
path: root/sync/tools
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-25 00:34:25 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-25 00:34:25 +0000
commit2bb83e405afd54dd75f88e024e6de1f6809a69d2 (patch)
tree5f4b1fe2607a03c6b0683fe108085f7952e547cc /sync/tools
parent138ab683463164ceec6789a550ea148ac679f112 (diff)
downloadchromium_src-2bb83e405afd54dd75f88e024e6de1f6809a69d2.zip
chromium_src-2bb83e405afd54dd75f88e024e6de1f6809a69d2.tar.gz
chromium_src-2bb83e405afd54dd75f88e024e6de1f6809a69d2.tar.bz2
[Sync] Fix sync_listen_notifications to use a real host resolver
r138413 switched TestURLRequestContext to use a mock HostResolver by default. Clean up sync DEPS a bit. BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/10435007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138947 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/tools')
-rw-r--r--sync/tools/DEPS1
-rw-r--r--sync/tools/sync_listen_notifications.cc38
2 files changed, 38 insertions, 1 deletions
diff --git a/sync/tools/DEPS b/sync/tools/DEPS
index befcabe..d3ae88f 100644
--- a/sync/tools/DEPS
+++ b/sync/tools/DEPS
@@ -1,6 +1,7 @@
include_rules = [
"+jingle/notifier/base",
"+net/base/host_port_pair.h",
+ "+net/base/host_resolver.h",
"+net/url_request/url_request_test_util.h",
"+sync/notifier",
"+sync/syncable/model_type.h",
diff --git a/sync/tools/sync_listen_notifications.cc b/sync/tools/sync_listen_notifications.cc
index 0b8f345..41ed284 100644
--- a/sync/tools/sync_listen_notifications.cc
+++ b/sync/tools/sync_listen_notifications.cc
@@ -18,6 +18,7 @@
#include "jingle/notifier/base/notification_method.h"
#include "jingle/notifier/base/notifier_options.h"
#include "net/base/host_port_pair.h"
+#include "net/base/host_resolver.h"
#include "net/url_request/url_request_test_util.h"
#include "sync/notifier/invalidation_state_tracker.h"
#include "sync/notifier/sync_notifier.h"
@@ -127,6 +128,41 @@ notifier::NotifierOptions ParseNotifierOptions(
return notifier_options;
}
+// Needed to use a real host resolver.
+class MyTestURLRequestContext : public TestURLRequestContext {
+ public:
+ MyTestURLRequestContext() : TestURLRequestContext(true) {
+ context_storage_.set_host_resolver(
+ net::CreateSystemHostResolver(
+ net::HostResolver::kDefaultParallelism,
+ net::HostResolver::kDefaultRetryAttempts,
+ NULL));
+ Init();
+ }
+
+ virtual ~MyTestURLRequestContext() {}
+};
+
+class MyTestURLRequestContextGetter : public TestURLRequestContextGetter {
+ public:
+ explicit MyTestURLRequestContextGetter(
+ const scoped_refptr<base::MessageLoopProxy>& io_message_loop_proxy)
+ : TestURLRequestContextGetter(io_message_loop_proxy) {}
+
+ virtual TestURLRequestContext* GetURLRequestContext() OVERRIDE {
+ // Construct |context_| lazily so it gets constructed on the right
+ // thread (the IO thread).
+ if (!context_.get())
+ context_.reset(new MyTestURLRequestContext());
+ return context_.get();
+ }
+
+ private:
+ virtual ~MyTestURLRequestContextGetter() {}
+
+ scoped_ptr<MyTestURLRequestContext> context_;
+};
+
} // namespace
int main(int argc, char* argv[]) {
@@ -169,7 +205,7 @@ int main(int argc, char* argv[]) {
const notifier::NotifierOptions& notifier_options =
ParseNotifierOptions(
command_line,
- new TestURLRequestContextGetter(io_thread.message_loop_proxy()));
+ new MyTestURLRequestContextGetter(io_thread.message_loop_proxy()));
const char kClientInfo[] = "sync_listen_notifications";
NullInvalidationStateTracker null_invalidation_state_tracker;
sync_notifier::SyncNotifierFactory sync_notifier_factory(