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

Side by Side Diff: chrome/browser/devtools/device/android_device_manager.cc

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/devtools/device/android_device_manager.h" 5 #include "chrome/browser/devtools/device/android_device_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <string.h> 8 #include <string.h>
9 #include <utility>
9 10
10 #include "base/location.h" 11 #include "base/location.h"
11 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
14 #include "base/thread_task_runner_handle.h" 15 #include "base/thread_task_runner_handle.h"
15 #include "net/base/io_buffer.h" 16 #include "net/base/io_buffer.h"
16 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
17 #include "net/socket/stream_socket.h" 18 #include "net/socket/stream_socket.h"
18 19
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 typedef AndroidDeviceManager::HttpUpgradeCallback HttpUpgradeCallback; 71 typedef AndroidDeviceManager::HttpUpgradeCallback HttpUpgradeCallback;
71 72
72 static void CommandRequest(const std::string& request, 73 static void CommandRequest(const std::string& request,
73 const CommandCallback& callback, 74 const CommandCallback& callback,
74 int result, 75 int result,
75 scoped_ptr<net::StreamSocket> socket) { 76 scoped_ptr<net::StreamSocket> socket) {
76 if (result != net::OK) { 77 if (result != net::OK) {
77 callback.Run(result, std::string()); 78 callback.Run(result, std::string());
78 return; 79 return;
79 } 80 }
80 new HttpRequest(socket.Pass(), request, callback); 81 new HttpRequest(std::move(socket), request, callback);
81 } 82 }
82 83
83 static void HttpUpgradeRequest(const std::string& request, 84 static void HttpUpgradeRequest(const std::string& request,
84 const HttpUpgradeCallback& callback, 85 const HttpUpgradeCallback& callback,
85 int result, 86 int result,
86 scoped_ptr<net::StreamSocket> socket) { 87 scoped_ptr<net::StreamSocket> socket) {
87 if (result != net::OK) { 88 if (result != net::OK) {
88 callback.Run( 89 callback.Run(
89 result, std::string(), std::string(), 90 result, std::string(), std::string(),
90 make_scoped_ptr<net::StreamSocket>(nullptr)); 91 make_scoped_ptr<net::StreamSocket>(nullptr));
91 return; 92 return;
92 } 93 }
93 new HttpRequest(socket.Pass(), request, callback); 94 new HttpRequest(std::move(socket), request, callback);
94 } 95 }
95 96
96 private: 97 private:
97 HttpRequest(scoped_ptr<net::StreamSocket> socket, 98 HttpRequest(scoped_ptr<net::StreamSocket> socket,
98 const std::string& request, 99 const std::string& request,
99 const CommandCallback& callback) 100 const CommandCallback& callback)
100 : socket_(socket.Pass()), 101 : socket_(std::move(socket)),
101 command_callback_(callback), 102 command_callback_(callback),
102 expected_size_(-1), 103 expected_size_(-1),
103 header_size_(0) { 104 header_size_(0) {
104 SendRequest(request); 105 SendRequest(request);
105 } 106 }
106 107
107 HttpRequest(scoped_ptr<net::StreamSocket> socket, 108 HttpRequest(scoped_ptr<net::StreamSocket> socket,
108 const std::string& request, 109 const std::string& request,
109 const HttpUpgradeCallback& callback) 110 const HttpUpgradeCallback& callback)
110 : socket_(socket.Pass()), 111 : socket_(std::move(socket)),
111 http_upgrade_callback_(callback), 112 http_upgrade_callback_(callback),
112 expected_size_(-1), 113 expected_size_(-1),
113 header_size_(0) { 114 header_size_(0) {
114 SendRequest(request); 115 SendRequest(request);
115 } 116 }
116 117
117 ~HttpRequest() { 118 ~HttpRequest() {
118 } 119 }
119 120
120 void DoSendRequest(int result) { 121 void DoSendRequest(int result) {
121 while (result != net::ERR_IO_PENDING) { 122 while (result != net::ERR_IO_PENDING) {
122 if (!CheckNetResultOrDie(result)) 123 if (!CheckNetResultOrDie(result))
123 return; 124 return;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // WebSocket handshake doesn't contain the Content-Length. For this case, 193 // WebSocket handshake doesn't contain the Content-Length. For this case,
193 // |expected_size_| is set to the size of the header (handshake). 194 // |expected_size_| is set to the size of the header (handshake).
194 // Some WebSocket frames can be already received into |response_|. 195 // Some WebSocket frames can be already received into |response_|.
195 if (static_cast<int>(response_.length()) >= expected_size_) { 196 if (static_cast<int>(response_.length()) >= expected_size_) {
196 const std::string& body = response_.substr(header_size_); 197 const std::string& body = response_.substr(header_size_);
197 if (!command_callback_.is_null()) { 198 if (!command_callback_.is_null()) {
198 command_callback_.Run(net::OK, body); 199 command_callback_.Run(net::OK, body);
199 } else { 200 } else {
200 // Pass the WebSocket frames (in |body|), too. 201 // Pass the WebSocket frames (in |body|), too.
201 http_upgrade_callback_.Run(net::OK, 202 http_upgrade_callback_.Run(net::OK,
202 ExtractHeader("Sec-WebSocket-Extensions:"), body, socket_.Pass()); 203 ExtractHeader("Sec-WebSocket-Extensions:"),
204 body, std::move(socket_));
203 } 205 }
204 delete this; 206 delete this;
205 return; 207 return;
206 } 208 }
207 209
208 result = socket_->Read( 210 result = socket_->Read(
209 response_buffer_.get(), 211 response_buffer_.get(),
210 kBufferSize, 212 kBufferSize,
211 base::Bind(&HttpRequest::OnResponseData, base::Unretained(this))); 213 base::Bind(&HttpRequest::OnResponseData, base::Unretained(this)));
212 if (result != net::ERR_IO_PENDING) 214 if (result != net::ERR_IO_PENDING)
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 new Device(handler_thread_->message_loop(), it->provider, it->serial); 542 new Device(handler_thread_->message_loop(), it->provider, it->serial);
541 } else { 543 } else {
542 device = found->second.get(); 544 device = found->second.get();
543 } 545 }
544 response.push_back(device); 546 response.push_back(device);
545 new_devices[it->serial] = device->weak_factory_.GetWeakPtr(); 547 new_devices[it->serial] = device->weak_factory_.GetWeakPtr();
546 } 548 }
547 devices_.swap(new_devices); 549 devices_.swap(new_devices);
548 callback.Run(response); 550 callback.Run(response);
549 } 551 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698