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

Side by Side Diff: remoting/host/setup/service_client.cc

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/setup/service_client.h" 5 #include "remoting/host/setup/service_client.h"
6 6
7 #include <memory>
8
7 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/values.h" 11 #include "base/values.h"
11 #include "net/http/http_status_code.h" 12 #include "net/http/http_status_code.h"
12 #include "net/url_request/url_fetcher.h" 13 #include "net/url_request/url_fetcher.h"
13 #include "net/url_request/url_fetcher_delegate.h" 14 #include "net/url_request/url_fetcher_delegate.h"
14 #include "net/url_request/url_request_context_getter.h" 15 #include "net/url_request/url_request_context_getter.h"
15 #include "url/gurl.h" 16 #include "url/gurl.h"
16 17
17 namespace remoting { 18 namespace remoting {
18 19
19 class ServiceClient::Core 20 class ServiceClient::Core
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 55
55 void MakeChromotingRequest(net::URLFetcher::RequestType request_type, 56 void MakeChromotingRequest(net::URLFetcher::RequestType request_type,
56 const std::string& post_body, 57 const std::string& post_body,
57 const std::string& url_suffix, 58 const std::string& url_suffix,
58 const std::string& oauth_access_token, 59 const std::string& oauth_access_token,
59 ServiceClient::Delegate* delegate); 60 ServiceClient::Delegate* delegate);
60 void HandleResponse(const net::URLFetcher* source); 61 void HandleResponse(const net::URLFetcher* source);
61 62
62 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; 63 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
63 ServiceClient::Delegate* delegate_; 64 ServiceClient::Delegate* delegate_;
64 scoped_ptr<net::URLFetcher> request_; 65 std::unique_ptr<net::URLFetcher> request_;
65 PendingRequestType pending_request_type_; 66 PendingRequestType pending_request_type_;
66 std::string chromoting_hosts_url_; 67 std::string chromoting_hosts_url_;
67 }; 68 };
68 69
69 void ServiceClient::Core::RegisterHost( 70 void ServiceClient::Core::RegisterHost(
70 const std::string& host_id, 71 const std::string& host_id,
71 const std::string& host_name, 72 const std::string& host_name,
72 const std::string& public_key, 73 const std::string& public_key,
73 const std::string& host_client_id, 74 const std::string& host_client_id,
74 const std::string& oauth_access_token, 75 const std::string& oauth_access_token,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // Treat codes 2xx as successful; for example, HTTP_NO_CONTENT (204) can be 139 // Treat codes 2xx as successful; for example, HTTP_NO_CONTENT (204) can be
139 // returned from a DELETE_REQUEST. 140 // returned from a DELETE_REQUEST.
140 if (source->GetResponseCode() / 100 == 2) { 141 if (source->GetResponseCode() / 100 == 2) {
141 switch (old_type) { 142 switch (old_type) {
142 case PENDING_REQUEST_NONE: 143 case PENDING_REQUEST_NONE:
143 break; 144 break;
144 case PENDING_REQUEST_REGISTER_HOST: 145 case PENDING_REQUEST_REGISTER_HOST:
145 { 146 {
146 std::string data; 147 std::string data;
147 source->GetResponseAsString(&data); 148 source->GetResponseAsString(&data);
148 scoped_ptr<base::Value> message_value = base::JSONReader::Read(data); 149 std::unique_ptr<base::Value> message_value =
150 base::JSONReader::Read(data);
149 base::DictionaryValue *dict; 151 base::DictionaryValue *dict;
150 std::string code; 152 std::string code;
151 if (message_value.get() && 153 if (message_value.get() &&
152 message_value->IsType(base::Value::TYPE_DICTIONARY) && 154 message_value->IsType(base::Value::TYPE_DICTIONARY) &&
153 message_value->GetAsDictionary(&dict) && 155 message_value->GetAsDictionary(&dict) &&
154 dict->GetString("data.authorizationCode", &code)) { 156 dict->GetString("data.authorizationCode", &code)) {
155 delegate_->OnHostRegistered(code); 157 delegate_->OnHostRegistered(code);
156 } else { 158 } else {
157 delegate_->OnHostRegistered(std::string()); 159 delegate_->OnHostRegistered(std::string());
158 } 160 }
(...skipping 28 matching lines...) Expand all
187 } 189 }
188 190
189 void ServiceClient::UnregisterHost( 191 void ServiceClient::UnregisterHost(
190 const std::string& host_id, 192 const std::string& host_id,
191 const std::string& oauth_access_token, 193 const std::string& oauth_access_token,
192 Delegate* delegate) { 194 Delegate* delegate) {
193 return core_->UnregisterHost(host_id, oauth_access_token, delegate); 195 return core_->UnregisterHost(host_id, oauth_access_token, delegate);
194 } 196 }
195 197
196 } // namespace gaia 198 } // namespace gaia
OLDNEW
« no previous file with comments | « remoting/host/setup/me2me_native_messaging_host_unittest.cc ('k') | remoting/host/setup/start_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698