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

Side by Side Diff: remoting/host/setup/me2me_native_messaging_host_main.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/me2me_native_messaging_host_main.h" 5 #include "remoting/host/setup/me2me_native_messaging_host_main.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 read_file = base::File(STDIN_FILENO); 195 read_file = base::File(STDIN_FILENO);
196 write_file = base::File(STDOUT_FILENO); 196 write_file = base::File(STDOUT_FILENO);
197 #else 197 #else
198 #error Not implemented. 198 #error Not implemented.
199 #endif 199 #endif
200 200
201 // OAuth client (for credential requests). IO thread is used for blocking 201 // OAuth client (for credential requests). IO thread is used for blocking
202 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter( 202 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter(
203 new URLRequestContextGetter(io_thread.task_runner(), 203 new URLRequestContextGetter(io_thread.task_runner(),
204 file_thread.task_runner())); 204 file_thread.task_runner()));
205 scoped_ptr<OAuthClient> oauth_client( 205 std::unique_ptr<OAuthClient> oauth_client(
206 new GaiaOAuthClient(url_request_context_getter)); 206 new GaiaOAuthClient(url_request_context_getter));
207 207
208 net::URLFetcher::SetIgnoreCertificateRequests(true); 208 net::URLFetcher::SetIgnoreCertificateRequests(true);
209 209
210 // Create the pairing registry. 210 // Create the pairing registry.
211 scoped_refptr<PairingRegistry> pairing_registry; 211 scoped_refptr<PairingRegistry> pairing_registry;
212 212
213 #if defined(OS_WIN) 213 #if defined(OS_WIN)
214 base::win::RegKey root; 214 base::win::RegKey root;
215 LONG result = root.Open(HKEY_LOCAL_MACHINE, kPairingRegistryKeyName, 215 LONG result = root.Open(HKEY_LOCAL_MACHINE, kPairingRegistryKeyName,
(...skipping 21 matching lines...) Expand all
237 KEY_READ | KEY_WRITE); 237 KEY_READ | KEY_WRITE);
238 if (result != ERROR_SUCCESS) { 238 if (result != ERROR_SUCCESS) {
239 SetLastError(result); 239 SetLastError(result);
240 PLOG(ERROR) << "Failed to open HKLM\\" << kPairingRegistryKeyName << "\\" 240 PLOG(ERROR) << "Failed to open HKLM\\" << kPairingRegistryKeyName << "\\"
241 << kPairingRegistrySecretsKeyName; 241 << kPairingRegistrySecretsKeyName;
242 return kInitializationFailed; 242 return kInitializationFailed;
243 } 243 }
244 } 244 }
245 245
246 // Initialize the pairing registry delegate and set the root keys. 246 // Initialize the pairing registry delegate and set the root keys.
247 scoped_ptr<PairingRegistryDelegateWin> delegate( 247 std::unique_ptr<PairingRegistryDelegateWin> delegate(
248 new PairingRegistryDelegateWin()); 248 new PairingRegistryDelegateWin());
249 if (!delegate->SetRootKeys(privileged.Take(), unprivileged.Take())) 249 if (!delegate->SetRootKeys(privileged.Take(), unprivileged.Take()))
250 return kInitializationFailed; 250 return kInitializationFailed;
251 251
252 pairing_registry = 252 pairing_registry =
253 new PairingRegistry(io_thread.task_runner(), std::move(delegate)); 253 new PairingRegistry(io_thread.task_runner(), std::move(delegate));
254 #else // defined(OS_WIN) 254 #else // defined(OS_WIN)
255 pairing_registry = 255 pairing_registry =
256 CreatePairingRegistry(io_thread.task_runner()); 256 CreatePairingRegistry(io_thread.task_runner());
257 #endif // !defined(OS_WIN) 257 #endif // !defined(OS_WIN)
258 258
259 // Set up the native messaging channel. 259 // Set up the native messaging channel.
260 scoped_ptr<extensions::NativeMessagingChannel> channel( 260 std::unique_ptr<extensions::NativeMessagingChannel> channel(
261 new PipeMessagingChannel(std::move(read_file), std::move(write_file))); 261 new PipeMessagingChannel(std::move(read_file), std::move(write_file)));
262 262
263 // Create the native messaging host. 263 // Create the native messaging host.
264 scoped_ptr<Me2MeNativeMessagingHost> host(new Me2MeNativeMessagingHost( 264 std::unique_ptr<Me2MeNativeMessagingHost> host(new Me2MeNativeMessagingHost(
265 needs_elevation, static_cast<intptr_t>(native_view_handle), 265 needs_elevation, static_cast<intptr_t>(native_view_handle),
266 std::move(channel), daemon_controller, pairing_registry, 266 std::move(channel), daemon_controller, pairing_registry,
267 std::move(oauth_client))); 267 std::move(oauth_client)));
268 host->Start(run_loop.QuitClosure()); 268 host->Start(run_loop.QuitClosure());
269 269
270 // Run the loop until channel is alive. 270 // Run the loop until channel is alive.
271 run_loop.Run(); 271 run_loop.Run();
272 return kSuccessExitCode; 272 return kSuccessExitCode;
273 } 273 }
274 274
275 int Me2MeNativeMessagingHostMain(int argc, char** argv) { 275 int Me2MeNativeMessagingHostMain(int argc, char** argv) {
276 // This object instance is required by Chrome code (such as MessageLoop). 276 // This object instance is required by Chrome code (such as MessageLoop).
277 base::AtExitManager exit_manager; 277 base::AtExitManager exit_manager;
278 278
279 base::CommandLine::Init(argc, argv); 279 base::CommandLine::Init(argc, argv);
280 remoting::InitHostLogging(); 280 remoting::InitHostLogging();
281 281
282 return StartMe2MeNativeMessagingHost(); 282 return StartMe2MeNativeMessagingHost();
283 } 283 }
284 284
285 } // namespace remoting 285 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/setup/me2me_native_messaging_host.cc ('k') | remoting/host/setup/me2me_native_messaging_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698