[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
This commit is contained in:
sync
@@ -7,9 +7,6 @@ include_rules = [
|
||||
"+base",
|
||||
"+build",
|
||||
"+testing",
|
||||
# TODO(kochi): Remove this hack after "Chromebox" hack in get_session_name.cc
|
||||
# is gone.
|
||||
"+chrome/browser/chromeos/system",
|
||||
|
||||
# Force subdirectories to explicitly define DEPS.
|
||||
"-sync",
|
||||
|
@@ -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",
|
||||
|
@@ -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(
|
||||
|
@@ -4,4 +4,8 @@ include_rules = [
|
||||
"+sync/syncable/model_type.h",
|
||||
"+sync/syncable/model_type_test_util.h",
|
||||
"+sync/test/fake_encryptor.h",
|
||||
|
||||
# TODO(kochi): Remove this hack after "Chromebox" hack in get_session_name.cc
|
||||
# is gone.
|
||||
"+chrome/browser/chromeos/system",
|
||||
]
|
||||
|
Reference in New Issue
Block a user