| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/host/service_client.h" | 5 #include "remoting/host/service_client.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 const std::string& oauth_access_token, | 71 const std::string& oauth_access_token, |
| 72 Delegate* delegate) { | 72 Delegate* delegate) { |
| 73 DCHECK(pending_request_type_ == PENDING_REQUEST_NONE); | 73 DCHECK(pending_request_type_ == PENDING_REQUEST_NONE); |
| 74 pending_request_type_ = PENDING_REQUEST_REGISTER_HOST; | 74 pending_request_type_ = PENDING_REQUEST_REGISTER_HOST; |
| 75 base::DictionaryValue post_body; | 75 base::DictionaryValue post_body; |
| 76 post_body.SetString("data.hostId", host_id); | 76 post_body.SetString("data.hostId", host_id); |
| 77 post_body.SetString("data.hostName", host_name); | 77 post_body.SetString("data.hostName", host_name); |
| 78 post_body.SetString("data.publicKey", public_key); | 78 post_body.SetString("data.publicKey", public_key); |
| 79 std::string post_body_str; | 79 std::string post_body_str; |
| 80 base::JSONWriter::Write(&post_body, &post_body_str); | 80 base::JSONWriter::Write(&post_body, &post_body_str); |
| 81 MakeGaiaRequest(net::URLFetcher::POST, "", post_body_str, oauth_access_token, | 81 MakeGaiaRequest(net::URLFetcher::POST, |
| 82 std::string(), |
| 83 post_body_str, |
| 84 oauth_access_token, |
| 82 delegate); | 85 delegate); |
| 83 } | 86 } |
| 84 | 87 |
| 85 void ServiceClient::Core::UnregisterHost( | 88 void ServiceClient::Core::UnregisterHost( |
| 86 const std::string& host_id, | 89 const std::string& host_id, |
| 87 const std::string& oauth_access_token, | 90 const std::string& oauth_access_token, |
| 88 Delegate* delegate) { | 91 Delegate* delegate) { |
| 89 DCHECK(pending_request_type_ == PENDING_REQUEST_NONE); | 92 DCHECK(pending_request_type_ == PENDING_REQUEST_NONE); |
| 90 pending_request_type_ = PENDING_REQUEST_UNREGISTER_HOST; | 93 pending_request_type_ = PENDING_REQUEST_UNREGISTER_HOST; |
| 91 MakeGaiaRequest(net::URLFetcher::DELETE_REQUEST, host_id, "", | 94 MakeGaiaRequest(net::URLFetcher::DELETE_REQUEST, |
| 92 oauth_access_token, delegate); | 95 host_id, |
| 96 std::string(), |
| 97 oauth_access_token, |
| 98 delegate); |
| 93 } | 99 } |
| 94 | 100 |
| 95 void ServiceClient::Core::MakeGaiaRequest( | 101 void ServiceClient::Core::MakeGaiaRequest( |
| 96 net::URLFetcher::RequestType request_type, | 102 net::URLFetcher::RequestType request_type, |
| 97 const std::string& url_suffix, | 103 const std::string& url_suffix, |
| 98 const std::string& request_body, | 104 const std::string& request_body, |
| 99 const std::string& oauth_access_token, | 105 const std::string& oauth_access_token, |
| 100 ServiceClient::Delegate* delegate) { | 106 ServiceClient::Delegate* delegate) { |
| 101 delegate_ = delegate; | 107 delegate_ = delegate; |
| 102 request_.reset(net::URLFetcher::Create( | 108 request_.reset(net::URLFetcher::Create( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } | 163 } |
| 158 | 164 |
| 159 void ServiceClient::UnregisterHost( | 165 void ServiceClient::UnregisterHost( |
| 160 const std::string& host_id, | 166 const std::string& host_id, |
| 161 const std::string& oauth_access_token, | 167 const std::string& oauth_access_token, |
| 162 Delegate* delegate) { | 168 Delegate* delegate) { |
| 163 return core_->UnregisterHost(host_id, oauth_access_token, delegate); | 169 return core_->UnregisterHost(host_id, oauth_access_token, delegate); |
| 164 } | 170 } |
| 165 | 171 |
| 166 } // namespace gaia | 172 } // namespace gaia |
| OLD | NEW |