Index: sync/tools/sync_listen_notifications.cc |
diff --git a/sync/tools/sync_listen_notifications.cc b/sync/tools/sync_listen_notifications.cc |
index 0b8f3451a3d885475c058ca4107b588f9138ce92..29fbbead100efdffc8fa77578ab9ad02b8a3a538 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,42 @@ 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()); |
+ } |
szym
2012/05/24 04:33:44
nit: no need for braces
akalin
2012/05/24 23:19:36
Done.
|
+ return context_.get(); |
+ } |
+ |
+ private: |
+ virtual ~MyTestURLRequestContextGetter() {} |
+ |
+ scoped_ptr<MyTestURLRequestContext> context_; |
+}; |
+ |
} // namespace |
int main(int argc, char* argv[]) { |
@@ -169,7 +206,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( |