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

Side by Side Diff: chrome/browser/android/dev_tools_server.cc

Issue 1551033002: Convert Pass()→std::move() in //chrome (Android edition) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 (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 "chrome/browser/android/dev_tools_server.h" 5 #include "chrome/browser/android/dev_tools_server.h"
6 6
7 #include <pwd.h> 7 #include <pwd.h>
8 #include <cstring> 8 #include <cstring>
9 #include <utility>
9 10
10 #include "base/android/context_utils.h" 11 #include "base/android/context_utils.h"
11 #include "base/android/jni_string.h" 12 #include "base/android/jni_string.h"
12 #include "base/bind.h" 13 #include "base/bind.h"
13 #include "base/callback.h" 14 #include "base/callback.h"
14 #include "base/command_line.h" 15 #include "base/command_line.h"
15 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
16 #include "base/files/file_path.h" 17 #include "base/files/file_path.h"
17 #include "base/logging.h" 18 #include "base/logging.h"
18 #include "base/macros.h" 19 #include "base/macros.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 auth_callback_(auth_callback) { 149 auth_callback_(auth_callback) {
149 } 150 }
150 151
151 private: 152 private:
152 scoped_ptr<net::ServerSocket> CreateForHttpServer() override { 153 scoped_ptr<net::ServerSocket> CreateForHttpServer() override {
153 scoped_ptr<net::ServerSocket> socket( 154 scoped_ptr<net::ServerSocket> socket(
154 new net::UnixDomainServerSocket(auth_callback_, 155 new net::UnixDomainServerSocket(auth_callback_,
155 true /* use_abstract_namespace */)); 156 true /* use_abstract_namespace */));
156 157
157 if (socket->ListenWithAddressAndPort(socket_name_, 0, kBackLog) == net::OK) 158 if (socket->ListenWithAddressAndPort(socket_name_, 0, kBackLog) == net::OK)
158 return socket.Pass(); 159 return socket;
159 160
160 // Try a fallback socket name. 161 // Try a fallback socket name.
161 const std::string fallback_address( 162 const std::string fallback_address(
162 base::StringPrintf("%s_%d", socket_name_.c_str(), getpid())); 163 base::StringPrintf("%s_%d", socket_name_.c_str(), getpid()));
163 if (socket->ListenWithAddressAndPort(fallback_address, 0, kBackLog) 164 if (socket->ListenWithAddressAndPort(fallback_address, 0, kBackLog)
164 == net::OK) 165 == net::OK)
165 return socket.Pass(); 166 return socket;
166 167
167 return scoped_ptr<net::ServerSocket>(); 168 return scoped_ptr<net::ServerSocket>();
168 } 169 }
169 170
170 scoped_ptr<net::ServerSocket> CreateForTethering(std::string* name) override { 171 scoped_ptr<net::ServerSocket> CreateForTethering(std::string* name) override {
171 *name = base::StringPrintf( 172 *name = base::StringPrintf(
172 kTetheringSocketName, getpid(), ++last_tethering_socket_); 173 kTetheringSocketName, getpid(), ++last_tethering_socket_);
173 scoped_ptr<net::UnixDomainServerSocket> socket( 174 scoped_ptr<net::UnixDomainServerSocket> socket(
174 new net::UnixDomainServerSocket(auth_callback_, true)); 175 new net::UnixDomainServerSocket(auth_callback_, true));
175 if (socket->ListenWithAddressAndPort(*name, 0, kBackLog) != net::OK) 176 if (socket->ListenWithAddressAndPort(*name, 0, kBackLog) != net::OK)
176 return scoped_ptr<net::ServerSocket>(); 177 return scoped_ptr<net::ServerSocket>();
177 178
178 return socket.Pass(); 179 return std::move(socket);
Lei Zhang 2015/12/29 23:59:30 Do you need the std::move() here?
dcheng 2015/12/30 00:08:53 Yes, since this converts from scoped_ptr<net::Unix
179 } 180 }
180 181
181 std::string socket_name_; 182 std::string socket_name_;
182 int last_tethering_socket_; 183 int last_tethering_socket_;
183 net::UnixDomainServerSocket::AuthCallback auth_callback_; 184 net::UnixDomainServerSocket::AuthCallback auth_callback_;
184 185
185 DISALLOW_COPY_AND_ASSIGN(UnixDomainServerSocketFactory); 186 DISALLOW_COPY_AND_ASSIGN(UnixDomainServerSocketFactory);
186 }; 187 };
187 188
188 } // namespace 189 } // namespace
(...skipping 18 matching lines...) Expand all
207 if (devtools_http_handler_) 208 if (devtools_http_handler_)
208 return; 209 return;
209 210
210 net::UnixDomainServerSocket::AuthCallback auth_callback = 211 net::UnixDomainServerSocket::AuthCallback auth_callback =
211 allow_debug_permission ? 212 allow_debug_permission ?
212 base::Bind(&AuthorizeSocketAccessWithDebugPermission) : 213 base::Bind(&AuthorizeSocketAccessWithDebugPermission) :
213 base::Bind(&content::CanUserConnectToDevTools); 214 base::Bind(&content::CanUserConnectToDevTools);
214 scoped_ptr<DevToolsHttpHandler::ServerSocketFactory> factory( 215 scoped_ptr<DevToolsHttpHandler::ServerSocketFactory> factory(
215 new UnixDomainServerSocketFactory(socket_name_, auth_callback)); 216 new UnixDomainServerSocketFactory(socket_name_, auth_callback));
216 devtools_http_handler_.reset(new DevToolsHttpHandler( 217 devtools_http_handler_.reset(new DevToolsHttpHandler(
217 factory.Pass(), 218 std::move(factory),
218 base::StringPrintf(kFrontEndURL, content::GetWebKitRevision().c_str()), 219 base::StringPrintf(kFrontEndURL, content::GetWebKitRevision().c_str()),
219 new DevToolsServerDelegate(), 220 new DevToolsServerDelegate(), base::FilePath(), base::FilePath(),
220 base::FilePath(), 221 version_info::GetProductNameAndVersionForUserAgent(), ::GetUserAgent()));
221 base::FilePath(),
222 version_info::GetProductNameAndVersionForUserAgent(),
223 ::GetUserAgent()));
224 } 222 }
225 223
226 void DevToolsServer::Stop() { 224 void DevToolsServer::Stop() {
227 devtools_http_handler_.reset(); 225 devtools_http_handler_.reset();
228 } 226 }
229 227
230 bool DevToolsServer::IsStarted() const { 228 bool DevToolsServer::IsStarted() const {
231 return devtools_http_handler_; 229 return devtools_http_handler_;
232 } 230 }
233 231
(...skipping 27 matching lines...) Expand all
261 jlong server, 259 jlong server,
262 jboolean enabled, 260 jboolean enabled,
263 jboolean allow_debug_permission) { 261 jboolean allow_debug_permission) {
264 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); 262 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server);
265 if (enabled) { 263 if (enabled) {
266 devtools_server->Start(allow_debug_permission); 264 devtools_server->Start(allow_debug_permission);
267 } else { 265 } else {
268 devtools_server->Stop(); 266 devtools_server->Stop();
269 } 267 }
270 } 268 }
OLDNEW
« no previous file with comments | « chrome/browser/android/data_usage/data_use_matcher.cc ('k') | chrome/browser/android/feedback/connectivity_checker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698