OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ui/webui/settings/certificates_handler.h" | 5 #include "chrome/browser/ui/webui/settings/certificates_handler.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 base::CancelableTaskTracker::TaskId FileAccessProvider::StartRead( | 293 base::CancelableTaskTracker::TaskId FileAccessProvider::StartRead( |
294 const base::FilePath& path, | 294 const base::FilePath& path, |
295 const ReadCallback& callback, | 295 const ReadCallback& callback, |
296 base::CancelableTaskTracker* tracker) { | 296 base::CancelableTaskTracker* tracker) { |
297 // Owned by reply callback posted below. | 297 // Owned by reply callback posted below. |
298 int* saved_errno = new int(0); | 298 int* saved_errno = new int(0); |
299 std::string* data = new std::string(); | 299 std::string* data = new std::string(); |
300 | 300 |
301 // Post task to file thread to read file. | 301 // Post task to file thread to read file. |
302 return tracker->PostTaskAndReply( | 302 return tracker->PostTaskAndReply( |
303 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get(), | 303 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get(), |
304 FROM_HERE, | 304 FROM_HERE, |
305 base::Bind(&FileAccessProvider::DoRead, this, path, saved_errno, data), | 305 base::Bind(&FileAccessProvider::DoRead, this, path, saved_errno, data), |
306 base::Bind(callback, base::Owned(saved_errno), base::Owned(data))); | 306 base::Bind(callback, base::Owned(saved_errno), base::Owned(data))); |
307 } | 307 } |
308 | 308 |
309 base::CancelableTaskTracker::TaskId FileAccessProvider::StartWrite( | 309 base::CancelableTaskTracker::TaskId FileAccessProvider::StartWrite( |
310 const base::FilePath& path, | 310 const base::FilePath& path, |
311 const std::string& data, | 311 const std::string& data, |
312 const WriteCallback& callback, | 312 const WriteCallback& callback, |
313 base::CancelableTaskTracker* tracker) { | 313 base::CancelableTaskTracker* tracker) { |
314 // Owned by reply callback posted below. | 314 // Owned by reply callback posted below. |
315 int* saved_errno = new int(0); | 315 int* saved_errno = new int(0); |
316 int* bytes_written = new int(0); | 316 int* bytes_written = new int(0); |
317 | 317 |
318 // Post task to file thread to write file. | 318 // Post task to file thread to write file. |
319 return tracker->PostTaskAndReply( | 319 return tracker->PostTaskAndReply( |
320 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get(), | 320 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get(), |
321 FROM_HERE, base::Bind(&FileAccessProvider::DoWrite, this, path, data, | 321 FROM_HERE, base::Bind(&FileAccessProvider::DoWrite, this, path, data, |
322 saved_errno, bytes_written), | 322 saved_errno, bytes_written), |
323 base::Bind(callback, base::Owned(saved_errno), | 323 base::Bind(callback, base::Owned(saved_errno), |
324 base::Owned(bytes_written))); | 324 base::Owned(bytes_written))); |
325 } | 325 } |
326 | 326 |
327 void FileAccessProvider::DoRead(const base::FilePath& path, | 327 void FileAccessProvider::DoRead(const base::FilePath& path, |
328 int* saved_errno, | 328 int* saved_errno, |
329 std::string* data) { | 329 std::string* data) { |
330 bool success = base::ReadFileToString(path, data); | 330 bool success = base::ReadFileToString(path, data); |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 error_info->Set(kCertificateErrors, | 1141 error_info->Set(kCertificateErrors, |
1142 base::WrapUnique(cert_error_list.release())); | 1142 base::WrapUnique(cert_error_list.release())); |
1143 RejectCallback(*error_info); | 1143 RejectCallback(*error_info); |
1144 } | 1144 } |
1145 | 1145 |
1146 gfx::NativeWindow CertificatesHandler::GetParentWindow() const { | 1146 gfx::NativeWindow CertificatesHandler::GetParentWindow() const { |
1147 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); | 1147 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); |
1148 } | 1148 } |
1149 | 1149 |
1150 } // namespace settings | 1150 } // namespace settings |
OLD | NEW |