OLD | NEW |
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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 : detached_(false), | 92 : detached_(false), |
93 allow_user_level_hosts_(allow_user_level_hosts), | 93 allow_user_level_hosts_(allow_user_level_hosts), |
94 window_handle_(window_handle) { | 94 window_handle_(window_handle) { |
95 } | 95 } |
96 | 96 |
97 NativeProcessLauncherImpl::Core::~Core() { | 97 NativeProcessLauncherImpl::Core::~Core() { |
98 DCHECK(detached_); | 98 DCHECK(detached_); |
99 } | 99 } |
100 | 100 |
101 void NativeProcessLauncherImpl::Core::Detach() { | 101 void NativeProcessLauncherImpl::Core::Detach() { |
102 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 102 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
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 LaunchedCallback callback) { | 109 LaunchedCallback callback) { |
110 content::BrowserThread::PostBlockingPoolTask( | 110 content::BrowserThread::PostBlockingPoolTask( |
111 FROM_HERE, base::Bind(&Core::DoLaunchOnThreadPool, this, | 111 FROM_HERE, base::Bind(&Core::DoLaunchOnThreadPool, this, |
112 origin, native_host_name, callback)); | 112 origin, native_host_name, callback)); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 PostErrorResult(callback, RESULT_FAILED_TO_START); | 192 PostErrorResult(callback, RESULT_FAILED_TO_START); |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 void NativeProcessLauncherImpl::Core::CallCallbackOnIOThread( | 196 void NativeProcessLauncherImpl::Core::CallCallbackOnIOThread( |
197 LaunchedCallback callback, | 197 LaunchedCallback callback, |
198 LaunchResult result, | 198 LaunchResult result, |
199 base::ProcessHandle process_handle, | 199 base::ProcessHandle process_handle, |
200 base::File read_file, | 200 base::File read_file, |
201 base::File write_file) { | 201 base::File write_file) { |
202 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 202 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
203 if (detached_) | 203 if (detached_) |
204 return; | 204 return; |
205 | 205 |
206 callback.Run(result, process_handle, read_file.Pass(), write_file.Pass()); | 206 callback.Run(result, process_handle, read_file.Pass(), write_file.Pass()); |
207 } | 207 } |
208 | 208 |
209 void NativeProcessLauncherImpl::Core::PostErrorResult( | 209 void NativeProcessLauncherImpl::Core::PostErrorResult( |
210 const LaunchedCallback& callback, | 210 const LaunchedCallback& callback, |
211 LaunchResult error) { | 211 LaunchResult error) { |
212 content::BrowserThread::PostTask( | 212 content::BrowserThread::PostTask( |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 intptr_t window_handle = 0; | 253 intptr_t window_handle = 0; |
254 #if defined(OS_WIN) | 254 #if defined(OS_WIN) |
255 window_handle = reinterpret_cast<intptr_t>( | 255 window_handle = reinterpret_cast<intptr_t>( |
256 views::HWNDForNativeView(native_view)); | 256 views::HWNDForNativeView(native_view)); |
257 #endif | 257 #endif |
258 return scoped_ptr<NativeProcessLauncher>( | 258 return scoped_ptr<NativeProcessLauncher>( |
259 new NativeProcessLauncherImpl(allow_user_level_hosts, window_handle)); | 259 new NativeProcessLauncherImpl(allow_user_level_hosts, window_handle)); |
260 } | 260 } |
261 | 261 |
262 } // namespace extensions | 262 } // namespace extensions |
OLD | NEW |