[cros] Make g_browser_process's call on the UI thread.

BUG=chromium-os:23417
TEST=browser_tests doesn't fail


Review URL: http://codereview.chromium.org/8688001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111544 0039d316-1c4b-4281-b951-d872f2087c98
parent 87320497
......@@ -63,28 +63,29 @@ void WebSocketProxyPrivate::Observe(
void WebSocketProxyPrivate::ResolveHost() {
#if defined(OS_CHROMEOS)
if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) {
content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
base::Bind(&WebSocketProxyPrivate::ResolveHost, this));
return;
}
IOThread* io_thread = g_browser_process->io_thread();
content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
base::Bind(&WebSocketProxyPrivate::ResolveHostIOPart, this, io_thread));
#endif
}
void WebSocketProxyPrivate::ResolveHostIOPart(IOThread* io_thread) {
#if defined(OS_CHROMEOS)
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
DCHECK(resolver_ == NULL);
if (g_browser_process) {
IOThread* io_thread = g_browser_process->io_thread();
if (io_thread && io_thread->globals()) {
net::HostResolver* host_resolver =
io_thread->globals()->host_resolver.get();
if (host_resolver) {
resolver_.reset(new net::SingleRequestHostResolver(host_resolver));
net::HostResolver::RequestInfo info(net::HostPortPair(
hostname_, port_));
int result = resolver_->Resolve(info, &addr_,
base::Bind(&WebSocketProxyPrivate::OnHostResolution, this),
net::BoundNetLog());
if (result != net::ERR_IO_PENDING)
OnHostResolution(result);
return;
}
if (io_thread && io_thread->globals()) {
net::HostResolver* host_resolver =
io_thread->globals()->host_resolver.get();
if (host_resolver) {
resolver_.reset(new net::SingleRequestHostResolver(host_resolver));
net::HostResolver::RequestInfo info(net::HostPortPair(
hostname_, port_));
int result = resolver_->Resolve(info, &addr_,
base::Bind(&WebSocketProxyPrivate::OnHostResolution, this),
net::BoundNetLog());
if (result != net::ERR_IO_PENDING)
OnHostResolution(result);
return;
}
}
NOTREACHED();
......
......@@ -12,6 +12,8 @@
#include "content/public/browser/notification_registrar.h"
#include "net/base/address_list.h"
class IOThread;
namespace net {
class SingleRequestHostResolver;
}
......@@ -56,8 +58,10 @@ class WebSocketProxyPrivate
// Callback for DNS resolution.
void OnHostResolution(int result);
// Executes on IO thread. Performs DNS resolution.
// Posts task to the IO thread, which will make dns resolution.
void ResolveHost();
// Executes on IO thread. Performs DNS resolution.
void ResolveHostIOPart(IOThread* io_thread);
// Used to signal timeout (when waiting for proxy initial launch).
base::OneShotTimer<WebSocketProxyPrivate> timer_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment