| OLD | NEW |
| 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 "chrome/browser/media_galleries/fileapi/supported_audio_video_checker.h
" | 5 #include "chrome/browser/media_galleries/fileapi/supported_audio_video_checker.h
" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 } // namespace | 56 } // namespace |
| 57 | 57 |
| 58 SupportedAudioVideoChecker::~SupportedAudioVideoChecker() {} | 58 SupportedAudioVideoChecker::~SupportedAudioVideoChecker() {} |
| 59 | 59 |
| 60 // static | 60 // static |
| 61 bool SupportedAudioVideoChecker::SupportsFileType(const base::FilePath& path) { | 61 bool SupportedAudioVideoChecker::SupportsFileType(const base::FilePath& path) { |
| 62 return g_audio_video_extensions.Get().HasSupportedAudioVideoExtension(path); | 62 return g_audio_video_extensions.Get().HasSupportedAudioVideoExtension(path); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void SupportedAudioVideoChecker::StartPreWriteValidation( | 65 void SupportedAudioVideoChecker::StartPreWriteValidation( |
| 66 const fileapi::CopyOrMoveFileValidator::ResultCallback& result_callback) { | 66 const storage::CopyOrMoveFileValidator::ResultCallback& result_callback) { |
| 67 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 67 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 68 DCHECK(callback_.is_null()); | 68 DCHECK(callback_.is_null()); |
| 69 callback_ = result_callback; | 69 callback_ = result_callback; |
| 70 | 70 |
| 71 content::BrowserThread::PostTaskAndReplyWithResult( | 71 content::BrowserThread::PostTaskAndReplyWithResult( |
| 72 content::BrowserThread::FILE, | 72 content::BrowserThread::FILE, |
| 73 FROM_HERE, | 73 FROM_HERE, |
| 74 base::Bind(&OpenOnFileThread, path_), | 74 base::Bind(&OpenOnFileThread, path_), |
| 75 base::Bind(&SupportedAudioVideoChecker::OnFileOpen, | 75 base::Bind(&SupportedAudioVideoChecker::OnFileOpen, |
| 76 weak_factory_.GetWeakPtr())); | 76 weak_factory_.GetWeakPtr())); |
| 77 } | 77 } |
| 78 | 78 |
| 79 SupportedAudioVideoChecker::SupportedAudioVideoChecker( | 79 SupportedAudioVideoChecker::SupportedAudioVideoChecker( |
| 80 const base::FilePath& path) | 80 const base::FilePath& path) |
| 81 : path_(path), | 81 : path_(path), |
| 82 weak_factory_(this) { | 82 weak_factory_(this) { |
| 83 } | 83 } |
| 84 | 84 |
| 85 void SupportedAudioVideoChecker::OnFileOpen(base::File file) { | 85 void SupportedAudioVideoChecker::OnFileOpen(base::File file) { |
| 86 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 86 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 87 if (!file.IsValid()) { | 87 if (!file.IsValid()) { |
| 88 callback_.Run(base::File::FILE_ERROR_SECURITY); | 88 callback_.Run(base::File::FILE_ERROR_SECURITY); |
| 89 return; | 89 return; |
| 90 } | 90 } |
| 91 | 91 |
| 92 safe_checker_ = new SafeAudioVideoChecker(file.Pass(), callback_); | 92 safe_checker_ = new SafeAudioVideoChecker(file.Pass(), callback_); |
| 93 safe_checker_->Start(); | 93 safe_checker_->Start(); |
| 94 } | 94 } |
| OLD | NEW |