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

Side by Side Diff: content/shell/browser/shell_devtools_manager_delegate.cc

Issue 1874903002: Convert //content from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix indent 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 "content/shell/browser/shell_devtools_manager_delegate.h" 5 #include "content/shell/browser/shell_devtools_manager_delegate.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ptr_util.h"
15 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #include "build/build_config.h" 19 #include "build/build_config.h"
19 #include "components/devtools_discovery/basic_target_descriptor.h" 20 #include "components/devtools_discovery/basic_target_descriptor.h"
20 #include "components/devtools_discovery/devtools_discovery_manager.h" 21 #include "components/devtools_discovery/devtools_discovery_manager.h"
21 #include "components/devtools_http_handler/devtools_http_handler.h" 22 #include "components/devtools_http_handler/devtools_http_handler.h"
22 #include "content/public/browser/browser_context.h" 23 #include "content/public/browser/browser_context.h"
23 #include "content/public/browser/devtools_agent_host.h" 24 #include "content/public/browser/devtools_agent_host.h"
24 #include "content/public/browser/devtools_frontend_host.h" 25 #include "content/public/browser/devtools_frontend_host.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 57
57 #if defined(OS_ANDROID) 58 #if defined(OS_ANDROID)
58 class UnixDomainServerSocketFactory 59 class UnixDomainServerSocketFactory
59 : public DevToolsHttpHandler::ServerSocketFactory { 60 : public DevToolsHttpHandler::ServerSocketFactory {
60 public: 61 public:
61 explicit UnixDomainServerSocketFactory(const std::string& socket_name) 62 explicit UnixDomainServerSocketFactory(const std::string& socket_name)
62 : socket_name_(socket_name) {} 63 : socket_name_(socket_name) {}
63 64
64 private: 65 private:
65 // DevToolsHttpHandler::ServerSocketFactory. 66 // DevToolsHttpHandler::ServerSocketFactory.
66 scoped_ptr<net::ServerSocket> CreateForHttpServer() override { 67 std::unique_ptr<net::ServerSocket> CreateForHttpServer() override {
67 scoped_ptr<net::UnixDomainServerSocket> socket( 68 std::unique_ptr<net::UnixDomainServerSocket> socket(
68 new net::UnixDomainServerSocket(base::Bind(&CanUserConnectToDevTools), 69 new net::UnixDomainServerSocket(base::Bind(&CanUserConnectToDevTools),
69 true /* use_abstract_namespace */)); 70 true /* use_abstract_namespace */));
70 if (socket->BindAndListen(socket_name_, kBackLog) != net::OK) 71 if (socket->BindAndListen(socket_name_, kBackLog) != net::OK)
71 return scoped_ptr<net::ServerSocket>(); 72 return std::unique_ptr<net::ServerSocket>();
72 73
73 return std::move(socket); 74 return std::move(socket);
74 } 75 }
75 76
76 std::string socket_name_; 77 std::string socket_name_;
77 78
78 DISALLOW_COPY_AND_ASSIGN(UnixDomainServerSocketFactory); 79 DISALLOW_COPY_AND_ASSIGN(UnixDomainServerSocketFactory);
79 }; 80 };
80 #else 81 #else
81 class TCPServerSocketFactory 82 class TCPServerSocketFactory
82 : public DevToolsHttpHandler::ServerSocketFactory { 83 : public DevToolsHttpHandler::ServerSocketFactory {
83 public: 84 public:
84 TCPServerSocketFactory(const std::string& address, uint16_t port) 85 TCPServerSocketFactory(const std::string& address, uint16_t port)
85 : address_(address), port_(port) {} 86 : address_(address), port_(port) {}
86 87
87 private: 88 private:
88 // DevToolsHttpHandler::ServerSocketFactory. 89 // DevToolsHttpHandler::ServerSocketFactory.
89 scoped_ptr<net::ServerSocket> CreateForHttpServer() override { 90 std::unique_ptr<net::ServerSocket> CreateForHttpServer() override {
90 scoped_ptr<net::ServerSocket> socket( 91 std::unique_ptr<net::ServerSocket> socket(
91 new net::TCPServerSocket(nullptr, net::NetLog::Source())); 92 new net::TCPServerSocket(nullptr, net::NetLog::Source()));
92 if (socket->ListenWithAddressAndPort(address_, port_, kBackLog) != net::OK) 93 if (socket->ListenWithAddressAndPort(address_, port_, kBackLog) != net::OK)
93 return scoped_ptr<net::ServerSocket>(); 94 return std::unique_ptr<net::ServerSocket>();
94 95
95 return socket; 96 return socket;
96 } 97 }
97 98
98 std::string address_; 99 std::string address_;
99 uint16_t port_; 100 uint16_t port_;
100 101
101 DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory); 102 DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory);
102 }; 103 };
103 #endif 104 #endif
104 105
105 scoped_ptr<DevToolsHttpHandler::ServerSocketFactory> 106 std::unique_ptr<DevToolsHttpHandler::ServerSocketFactory>
106 CreateSocketFactory() { 107 CreateSocketFactory() {
107 const base::CommandLine& command_line = 108 const base::CommandLine& command_line =
108 *base::CommandLine::ForCurrentProcess(); 109 *base::CommandLine::ForCurrentProcess();
109 #if defined(OS_ANDROID) 110 #if defined(OS_ANDROID)
110 std::string socket_name = "content_shell_devtools_remote"; 111 std::string socket_name = "content_shell_devtools_remote";
111 if (command_line.HasSwitch(switches::kRemoteDebuggingSocketName)) { 112 if (command_line.HasSwitch(switches::kRemoteDebuggingSocketName)) {
112 socket_name = command_line.GetSwitchValueASCII( 113 socket_name = command_line.GetSwitchValueASCII(
113 switches::kRemoteDebuggingSocketName); 114 switches::kRemoteDebuggingSocketName);
114 } 115 }
115 return scoped_ptr<DevToolsHttpHandler::ServerSocketFactory>( 116 return std::unique_ptr<DevToolsHttpHandler::ServerSocketFactory>(
116 new UnixDomainServerSocketFactory(socket_name)); 117 new UnixDomainServerSocketFactory(socket_name));
117 #else 118 #else
118 // See if the user specified a port on the command line (useful for 119 // See if the user specified a port on the command line (useful for
119 // automation). If not, use an ephemeral port by specifying 0. 120 // automation). If not, use an ephemeral port by specifying 0.
120 uint16_t port = 0; 121 uint16_t port = 0;
121 if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) { 122 if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) {
122 int temp_port; 123 int temp_port;
123 std::string port_str = 124 std::string port_str =
124 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort); 125 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort);
125 if (base::StringToInt(port_str, &temp_port) && 126 if (base::StringToInt(port_str, &temp_port) &&
126 temp_port >= 0 && temp_port < 65535) { 127 temp_port >= 0 && temp_port < 65535) {
127 port = static_cast<uint16_t>(temp_port); 128 port = static_cast<uint16_t>(temp_port);
128 } else { 129 } else {
129 DLOG(WARNING) << "Invalid http debugger port number " << temp_port; 130 DLOG(WARNING) << "Invalid http debugger port number " << temp_port;
130 } 131 }
131 } 132 }
132 return scoped_ptr<DevToolsHttpHandler::ServerSocketFactory>( 133 return std::unique_ptr<DevToolsHttpHandler::ServerSocketFactory>(
133 new TCPServerSocketFactory("127.0.0.1", port)); 134 new TCPServerSocketFactory("127.0.0.1", port));
134 #endif 135 #endif
135 } 136 }
136 137
137 scoped_ptr<devtools_discovery::DevToolsTargetDescriptor> 138 std::unique_ptr<devtools_discovery::DevToolsTargetDescriptor>
138 CreateNewShellTarget(BrowserContext* browser_context, const GURL& url) { 139 CreateNewShellTarget(BrowserContext* browser_context, const GURL& url) {
139 Shell* shell = Shell::CreateNewWindow(browser_context, 140 Shell* shell = Shell::CreateNewWindow(browser_context,
140 url, 141 url,
141 nullptr, 142 nullptr,
142 gfx::Size()); 143 gfx::Size());
143 return make_scoped_ptr(new devtools_discovery::BasicTargetDescriptor( 144 return base::WrapUnique(new devtools_discovery::BasicTargetDescriptor(
144 DevToolsAgentHost::GetOrCreateFor(shell->web_contents()))); 145 DevToolsAgentHost::GetOrCreateFor(shell->web_contents())));
145 } 146 }
146 147
147 // ShellDevToolsDelegate ---------------------------------------------------- 148 // ShellDevToolsDelegate ----------------------------------------------------
148 149
149 class ShellDevToolsDelegate : 150 class ShellDevToolsDelegate :
150 public devtools_http_handler::DevToolsHttpHandlerDelegate { 151 public devtools_http_handler::DevToolsHttpHandlerDelegate {
151 public: 152 public:
152 explicit ShellDevToolsDelegate(BrowserContext* browser_context); 153 explicit ShellDevToolsDelegate(BrowserContext* browser_context);
153 ~ShellDevToolsDelegate() override; 154 ~ShellDevToolsDelegate() override;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 ShellDevToolsManagerDelegate::~ShellDevToolsManagerDelegate() { 227 ShellDevToolsManagerDelegate::~ShellDevToolsManagerDelegate() {
227 } 228 }
228 229
229 base::DictionaryValue* ShellDevToolsManagerDelegate::HandleCommand( 230 base::DictionaryValue* ShellDevToolsManagerDelegate::HandleCommand(
230 DevToolsAgentHost* agent_host, 231 DevToolsAgentHost* agent_host,
231 base::DictionaryValue* command) { 232 base::DictionaryValue* command) {
232 return NULL; 233 return NULL;
233 } 234 }
234 235
235 } // namespace content 236 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/shell_devtools_frontend.cc ('k') | content/shell/browser/shell_javascript_dialog_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698