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

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: Rebase 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
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..6df387f25cc0d62a2ca9c7778b95246d734c278d 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,
+ net::URLFetcherDelegate {
Wez 2012/06/22 20:14:39 Style guide requires inheritance to be public.
Jamie 2012/06/22 22:42:02 Done.
public:
HostPortAllocatorSession(
cricket::HttpPortAllocatorBase* allocator,
@@ -36,13 +39,10 @@ class HostPortAllocatorSession
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);
+ void OnURLFetchComplete(const net::URLFetcher* url_fetcher);
Wez 2012/06/22 20:14:39 nit: "net::URLFetcherDelegate interface"
Jamie 2012/06/22 22:42:02 Done.
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 +86,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) {
Wez 2012/06/22 20:14:39 nit: source -> url_fetcher?
Wez 2012/06/22 20:14:39 Why does OnURLFetchComplete get passed a const net
Jamie 2012/06/22 22:42:02 It's called source elsewhere, including in the URL
Jamie 2012/06/22 22:42:02 There's a comment on the Start() method that says
+ 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);
}

Powered by Google App Engine
This is Rietveld 408576698