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

Side by Side Diff: chrome/browser/extensions/extension_web_socket_proxy_private_api.cc

Issue 8688001: [cros] Make g_browser_process's call on the UI thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/extension_web_socket_proxy_private_api.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/extension_web_socket_proxy_private_api.h" 5 #include "chrome/browser/extensions/extension_web_socket_proxy_private_api.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #else 56 #else
57 NOTREACHED(); 57 NOTREACHED();
58 #endif 58 #endif
59 59
60 timer_.Stop(); // Cancel timeout timer. 60 timer_.Stop(); // Cancel timeout timer.
61 ResolveHost(); 61 ResolveHost();
62 } 62 }
63 63
64 void WebSocketProxyPrivate::ResolveHost() { 64 void WebSocketProxyPrivate::ResolveHost() {
65 #if defined(OS_CHROMEOS) 65 #if defined(OS_CHROMEOS)
66 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { 66 IOThread* io_thread = g_browser_process->io_thread();
stevenjb 2011/11/28 18:45:39 One reason that g_browser_process->io_thread() is
altimofeev 2011/11/29 12:30:20 Please find my answers inline. On 2011/11/28 18:4
67 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, 67 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
68 base::Bind(&WebSocketProxyPrivate::ResolveHost, this)); 68 base::Bind(&WebSocketProxyPrivate::ResolveHostIOPart, this, io_thread));
69 return; 69 #endif
70 } 70 }
71
72 void WebSocketProxyPrivate::ResolveHostIOPart(IOThread* io_thread) {
73 #if defined(OS_CHROMEOS)
74 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
71 DCHECK(resolver_ == NULL); 75 DCHECK(resolver_ == NULL);
72 if (g_browser_process) { 76 if (io_thread && io_thread->globals()) {
73 IOThread* io_thread = g_browser_process->io_thread(); 77 net::HostResolver* host_resolver =
74 if (io_thread && io_thread->globals()) { 78 io_thread->globals()->host_resolver.get();
75 net::HostResolver* host_resolver = 79 if (host_resolver) {
76 io_thread->globals()->host_resolver.get(); 80 resolver_.reset(new net::SingleRequestHostResolver(host_resolver));
77 if (host_resolver) { 81 net::HostResolver::RequestInfo info(net::HostPortPair(
78 resolver_.reset(new net::SingleRequestHostResolver(host_resolver)); 82 hostname_, port_));
79 net::HostResolver::RequestInfo info(net::HostPortPair( 83 int result = resolver_->Resolve(info, &addr_,
80 hostname_, port_)); 84 base::Bind(&WebSocketProxyPrivate::OnHostResolution, this),
81 int result = resolver_->Resolve(info, &addr_, 85 net::BoundNetLog());
82 base::Bind(&WebSocketProxyPrivate::OnHostResolution, this), 86 if (result != net::ERR_IO_PENDING)
83 net::BoundNetLog()); 87 OnHostResolution(result);
84 if (result != net::ERR_IO_PENDING) 88 return;
85 OnHostResolution(result);
86 return;
87 }
88 } 89 }
89 } 90 }
90 NOTREACHED(); 91 NOTREACHED();
91 OnHostResolution(net::ERR_UNEXPECTED); 92 OnHostResolution(net::ERR_UNEXPECTED);
92 #endif 93 #endif
93 } 94 }
94 95
95 bool WebSocketProxyPrivate::RunImpl() { 96 bool WebSocketProxyPrivate::RunImpl() {
96 AddRef(); 97 AddRef();
97 result_.reset(Value::CreateStringValue("")); 98 result_.reset(Value::CreateStringValue(""));
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 void WebSocketProxyPrivateGetPassportForTCPFunction::CustomFinalize() { 206 void WebSocketProxyPrivateGetPassportForTCPFunction::CustomFinalize() {
206 #if defined(OS_CHROMEOS) 207 #if defined(OS_CHROMEOS)
207 std::string passport = 208 std::string passport =
208 browser::InternalAuthGeneration::GeneratePassport( 209 browser::InternalAuthGeneration::GeneratePassport(
209 "web_socket_proxy", map_) + std::string(":"); 210 "web_socket_proxy", map_) + std::string(":");
210 if (ContainsKey(map_, "addr")) 211 if (ContainsKey(map_, "addr"))
211 passport += map_["addr"]; 212 passport += map_["addr"];
212 result_.reset(Value::CreateStringValue(passport)); 213 result_.reset(Value::CreateStringValue(passport));
213 #endif 214 #endif
214 } 215 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_web_socket_proxy_private_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698