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

Side by Side Diff: chrome/browser/extensions/api/messaging/native_process_launcher.cc

Issue 2825963003: Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/extensions (Closed)
Patch Set: Created 3 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 (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/extensions/api/messaging/native_process_launcher.h" 5 #include "chrome/browser/extensions/api/messaging/native_process_launcher.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 detached_ = true; 103 detached_ = true;
104 } 104 }
105 105
106 void NativeProcessLauncherImpl::Core::Launch( 106 void NativeProcessLauncherImpl::Core::Launch(
107 const GURL& origin, 107 const GURL& origin,
108 const std::string& native_host_name, 108 const std::string& native_host_name,
109 const LaunchedCallback& callback) { 109 const LaunchedCallback& callback) {
110 base::PostTaskWithTraits(FROM_HERE, 110 base::PostTaskWithTraits(FROM_HERE,
111 base::TaskTraits().MayBlock().WithPriority( 111 base::TaskTraits().MayBlock().WithPriority(
112 base::TaskPriority::USER_VISIBLE), 112 base::TaskPriority::USER_VISIBLE),
113 base::Bind(&Core::DoLaunchOnThreadPool, this, origin, 113 base::BindOnce(&Core::DoLaunchOnThreadPool, this,
114 native_host_name, callback)); 114 origin, native_host_name, callback));
115 } 115 }
116 116
117 void NativeProcessLauncherImpl::Core::DoLaunchOnThreadPool( 117 void NativeProcessLauncherImpl::Core::DoLaunchOnThreadPool(
118 const GURL& origin, 118 const GURL& origin,
119 const std::string& native_host_name, 119 const std::string& native_host_name,
120 const LaunchedCallback& callback) { 120 const LaunchedCallback& callback) {
121 if (!NativeMessagingHostManifest::IsValidName(native_host_name)) { 121 if (!NativeMessagingHostManifest::IsValidName(native_host_name)) {
122 PostErrorResult(callback, RESULT_INVALID_NAME); 122 PostErrorResult(callback, RESULT_INVALID_NAME);
123 return; 123 return;
124 } 124 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 220
221 callback.Run(result, std::move(process), std::move(read_file), 221 callback.Run(result, std::move(process), std::move(read_file),
222 std::move(write_file)); 222 std::move(write_file));
223 } 223 }
224 224
225 void NativeProcessLauncherImpl::Core::PostErrorResult( 225 void NativeProcessLauncherImpl::Core::PostErrorResult(
226 const LaunchedCallback& callback, 226 const LaunchedCallback& callback,
227 LaunchResult error) { 227 LaunchResult error) {
228 content::BrowserThread::PostTask( 228 content::BrowserThread::PostTask(
229 content::BrowserThread::IO, FROM_HERE, 229 content::BrowserThread::IO, FROM_HERE,
230 base::Bind(&NativeProcessLauncherImpl::Core::CallCallbackOnIOThread, this, 230 base::BindOnce(&NativeProcessLauncherImpl::Core::CallCallbackOnIOThread,
231 callback, error, Passed(base::Process()), 231 this, callback, error, Passed(base::Process()),
232 Passed(base::File()), Passed(base::File()))); 232 Passed(base::File()), Passed(base::File())));
233 } 233 }
234 234
235 void NativeProcessLauncherImpl::Core::PostResult( 235 void NativeProcessLauncherImpl::Core::PostResult(
236 const LaunchedCallback& callback, 236 const LaunchedCallback& callback,
237 base::Process process, 237 base::Process process,
238 base::File read_file, 238 base::File read_file,
239 base::File write_file) { 239 base::File write_file) {
240 content::BrowserThread::PostTask( 240 content::BrowserThread::PostTask(
241 content::BrowserThread::IO, FROM_HERE, 241 content::BrowserThread::IO, FROM_HERE,
242 base::Bind(&NativeProcessLauncherImpl::Core::CallCallbackOnIOThread, this, 242 base::BindOnce(&NativeProcessLauncherImpl::Core::CallCallbackOnIOThread,
243 callback, RESULT_SUCCESS, Passed(&process), 243 this, callback, RESULT_SUCCESS, Passed(&process),
244 Passed(&read_file), Passed(&write_file))); 244 Passed(&read_file), Passed(&write_file)));
245 } 245 }
246 246
247 NativeProcessLauncherImpl::NativeProcessLauncherImpl( 247 NativeProcessLauncherImpl::NativeProcessLauncherImpl(
248 bool allow_user_level_hosts, 248 bool allow_user_level_hosts,
249 intptr_t window_handle) 249 intptr_t window_handle)
250 : core_(new Core(allow_user_level_hosts, window_handle)) { 250 : core_(new Core(allow_user_level_hosts, window_handle)) {
251 } 251 }
252 252
253 NativeProcessLauncherImpl::~NativeProcessLauncherImpl() { 253 NativeProcessLauncherImpl::~NativeProcessLauncherImpl() {
254 core_->Detach(); 254 core_->Detach();
(...skipping 14 matching lines...) Expand all
269 intptr_t window_handle = 0; 269 intptr_t window_handle = 0;
270 #if defined(OS_WIN) 270 #if defined(OS_WIN)
271 window_handle = reinterpret_cast<intptr_t>( 271 window_handle = reinterpret_cast<intptr_t>(
272 views::HWNDForNativeView(native_view)); 272 views::HWNDForNativeView(native_view));
273 #endif 273 #endif
274 return std::unique_ptr<NativeProcessLauncher>( 274 return std::unique_ptr<NativeProcessLauncher>(
275 new NativeProcessLauncherImpl(allow_user_level_hosts, window_handle)); 275 new NativeProcessLauncherImpl(allow_user_level_hosts, window_handle));
276 } 276 }
277 277
278 } // namespace extensions 278 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698