diff options
author | jamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-23 08:35:26 +0000 |
---|---|---|
committer | jamiewalch@chromium.org <jamiewalch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-23 08:35:26 +0000 |
commit | 7cf563aba8f4b3bab68e9bfe43824d952241dcf7 (patch) | |
tree | 5479b6a935fc14982f84486a9b7a28327b91d015 /remoting/host/host_port_allocator.cc | |
parent | 63bb8be277a8fb339243aa8ead02bdcdbc2937fe (diff) | |
download | chromium_src-7cf563aba8f4b3bab68e9bfe43824d952241dcf7.zip chromium_src-7cf563aba8f4b3bab68e9bfe43824d952241dcf7.tar.gz chromium_src-7cf563aba8f4b3bab68e9bfe43824d952241dcf7.tar.bz2 |
Remove UrlFetcher from remoting and use the one in net instead.
BUG=133790
TEST=Stop and restart the Me2Me host. It should still work.
Review URL: https://chromiumcodereview.appspot.com/10637008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143798 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/host_port_allocator.cc')
-rw-r--r-- | remoting/host/host_port_allocator.cc | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/remoting/host/host_port_allocator.cc b/remoting/host/host_port_allocator.cc index ad3a685..ff8e780 100644 --- a/remoting/host/host_port_allocator.cc +++ b/remoting/host/host_port_allocator.cc @@ -9,6 +9,8 @@ #include "base/string_number_conversions.h" #include "googleurl/src/gurl.h" #include "net/http/http_status_code.h" +#include "net/url_request/url_fetcher.h" +#include "net/url_request/url_fetcher_delegate.h" #include "net/url_request/url_request_context_getter.h" #include "remoting/host/network_settings.h" #include "third_party/libjingle/source/talk/base/basicpacketsocketfactory.h" @@ -18,7 +20,8 @@ namespace remoting { namespace { class HostPortAllocatorSession - : public cricket::HttpPortAllocatorSessionBase { + : public cricket::HttpPortAllocatorSessionBase, + public net::URLFetcherDelegate { public: HostPortAllocatorSession( cricket::HttpPortAllocatorBase* allocator, @@ -35,14 +38,12 @@ class HostPortAllocatorSession virtual void ConfigReady(cricket::PortConfiguration* config) OVERRIDE; virtual void SendSessionRequest(const std::string& host, int port) OVERRIDE; - private: - void OnSessionRequestDone(UrlFetcher* url_fetcher, - const net::URLRequestStatus& status, - int response_code, - const std::string& response); + // net::URLFetcherDelegate interface. + virtual void OnURLFetchComplete(const net::URLFetcher* url_fetcher) OVERRIDE; + private: scoped_refptr<net::URLRequestContextGetter> url_context_; - std::set<UrlFetcher*> url_fetchers_; + std::set<const net::URLFetcher*> url_fetchers_; DISALLOW_COPY_AND_ASSIGN(HostPortAllocatorSession); }; @@ -86,31 +87,31 @@ void HostPortAllocatorSession::SendSessionRequest(const std::string& host, int port) { GURL url("https://" + host + ":" + base::IntToString(port) + GetSessionRequestUrl() + "&sn=1"); - scoped_ptr<UrlFetcher> url_fetcher(new UrlFetcher(url, UrlFetcher::GET)); + scoped_ptr<net::URLFetcher> url_fetcher( + net::URLFetcher::Create(url, net::URLFetcher::GET, this)); url_fetcher->SetRequestContext(url_context_); - url_fetcher->SetHeader("X-Talk-Google-Relay-Auth", relay_token()); - url_fetcher->SetHeader("X-Google-Relay-Auth", relay_token()); - url_fetcher->SetHeader("X-Stream-Type", "chromoting"); - url_fetcher->Start(base::Bind(&HostPortAllocatorSession::OnSessionRequestDone, - base::Unretained(this), url_fetcher.get())); + url_fetcher->AddExtraRequestHeader( + "X-Talk-Google-Relay-Auth: " + relay_token()); + url_fetcher->AddExtraRequestHeader("X-Google-Relay-Auth: " + relay_token()); + url_fetcher->AddExtraRequestHeader("X-Stream-Type: chromoting"); + url_fetcher->Start(); url_fetchers_.insert(url_fetcher.release()); } -void HostPortAllocatorSession::OnSessionRequestDone( - UrlFetcher* url_fetcher, - const net::URLRequestStatus& status, - int response_code, - const std::string& response) { - url_fetchers_.erase(url_fetcher); - delete url_fetcher; +void HostPortAllocatorSession::OnURLFetchComplete( + const net::URLFetcher* source) { + url_fetchers_.erase(source); + delete source; - if (response_code != net::HTTP_OK) { + if (source->GetResponseCode() != net::HTTP_OK) { LOG(WARNING) << "Received error when allocating relay session: " - << response_code; + << source->GetResponseCode(); TryCreateRelaySession(); return; } + std::string response; + source->GetResponseAsString(&response); ReceiveSessionResponse(response); } |