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

Unified Diff: remoting/host/host_port_allocator.cc

Issue 10637008: Remove UrlFetcher from remoting and use the one in net instead. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use enum instead of bool to distinguish fetchers. Created 8 years, 6 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 | « remoting/host/host_port_allocator.h ('k') | remoting/host/url_fetcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/host_port_allocator.cc
diff --git a/remoting/host/host_port_allocator.cc b/remoting/host/host_port_allocator.cc
index ad3a6851f0141de1d302623c450c8e31ed261ce4..ff8e780e15c015f49ccec45c2e412176309d2615 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);
}
« no previous file with comments | « remoting/host/host_port_allocator.h ('k') | remoting/host/url_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698