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

Unified Diff: chrome/service/remoting/remoting_directory_service.cc

Issue 6036001: Move directory code from chrome/service to chrome/browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merges Created 10 years 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 | « chrome/service/remoting/remoting_directory_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/service/remoting/remoting_directory_service.cc
diff --git a/chrome/service/remoting/remoting_directory_service.cc b/chrome/service/remoting/remoting_directory_service.cc
deleted file mode 100644
index e61c0fdcebea3726bf5ab05c158d812de663bb5c..0000000000000000000000000000000000000000
--- a/chrome/service/remoting/remoting_directory_service.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <vector>
-
-#include "base/json/json_reader.h"
-#include "base/json/json_writer.h"
-#include "base/values.h"
-#include "chrome/common/guid.h"
-#include "chrome/common/net/url_request_context_getter.h"
-#include "chrome/service/net/service_url_request_context.h"
-#include "chrome/service/remoting/remoting_directory_service.h"
-#include "net/base/net_util.h"
-#include "net/http/http_request_headers.h"
-#include "remoting/host/host_key_pair.h"
-
-static const char kRemotingDirectoryUrl[] =
- "https://www.googleapis.com/chromoting/v1/@me/hosts";
-
-RemotingDirectoryService::RemotingDirectoryService(Client* client)
- : client_(client) {
-}
-
-RemotingDirectoryService::~RemotingDirectoryService() {
- DCHECK(!fetcher_.get()) << "URLFetcher not destroyed.";
-}
-
-void RemotingDirectoryService::AddHost(const std::string& token) {
- // TODO(hclam): This is a time consuming operation so we should run it on
- // a separate thread.
- host_key_pair_.reset(new remoting::HostKeyPair());
- host_key_pair_->Generate();
-
- // Get a host name and generate a UUID for the request.
- host_id_ = guid::GenerateGUID();
- host_name_ = net::GetHostName();
-
- // Prepare the parameters for the request.
- DictionaryValue data;
- data.SetString("hostId", host_id_);
- data.SetString("hostName", host_name_);
- data.SetString("publicKey", host_key_pair_->GetPublicKey());
-
- // Generate the final json query.
- DictionaryValue args;
- args.Set("data", data.DeepCopy());
- std::string request_content;
- base::JSONWriter::Write(&args, false, &request_content);
-
- // Prepare the HTTP header for authentication.
- net::HttpRequestHeaders headers;
- headers.SetHeader("Authorization", "GoogleLogin auth=" + token);
- fetcher_.reset(
- new URLFetcher(GURL(kRemotingDirectoryUrl), URLFetcher::POST, this));
- fetcher_->set_request_context(new ServiceURLRequestContextGetter());
- fetcher_->set_upload_data("application/json", request_content);
- fetcher_->set_extra_request_headers(headers.ToString());
-
- // And then start the request.
- fetcher_->Start();
-}
-
-void RemotingDirectoryService::CancelRequest() {
- fetcher_.reset();
-}
-
-void RemotingDirectoryService::OnURLFetchComplete(
- const URLFetcher* source,
- const GURL& url,
- const URLRequestStatus& status,
- int response_code,
- const ResponseCookies& cookies,
- const std::string& data) {
- // Destroy the fetcher after the response has been received.
- fetcher_.reset();
-
- // TODO(hclam): Simply checking 200 status is not enough.
- if (response_code == 200) {
- client_->OnRemotingHostAdded();
- } else {
- client_->OnRemotingDirectoryError();
- }
-}
« no previous file with comments | « chrome/service/remoting/remoting_directory_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698