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

Unified Diff: sync/tools/sync_listen_notifications.cc

Issue 10435007: [Sync] Fix sync_listen_notifications to use a real host resolver (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix DEPS Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/tools/DEPS ('k') | sync/util/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
« no previous file with comments | « sync/tools/DEPS ('k') | sync/util/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698